I’m fairly new to Swift, and I’ve stumbled across this problem today which will help me a lot if answered. The code below explains my issue:
struct Foo {
var x: Float
mutating func change() {
x += 1
}
}
struct Bar {
var y: Float
}
var foo = Foo(x: 1)
let bar = Bar(y: foo.x)
foo.change()
print(foo.x) // 2.0
print(bar.y) // 1.0 (how can I make this 2.0 as well?)
I thought I might have to use pointers but I have no idea how to, and I have no clue if that’d even work. Any ideas will help!
barbecause you declared it withlet. And you are not doing anything that would changebarin any case, so what would change it?