Thanks for the reply!!!!
I'm using Xcode
Version 15.2 (15C500b)
Don't know if that helps.
Also to be clear, this isn't my code, rather it's code from Day 11 of 100 days with SwiftUI from this website. The only thing I changed was var funds = 0
to private var funds = 0
per the suggestion of the website.
I restarted Xcode opened a new playground and can't recreate the error code that you get.
Xcode doesn't offer me 'funds' as a type ahead suggestion, but I'm able to type out account.funds = -1500
without any problem.
This seems to be a bug.
Below is the entire code:
import UIKit
struct BankAccount {
private var funds = 0
mutating func deposit(amount: Int) {
funds += amount
}
mutating func withdraw(amount: Int) -> Bool {
if funds >= amount {
funds -= amount
return true
} else {
return false
}
}
}
var account = BankAccount()
account.deposit(amount: 1000)
print(account.funds)
account.funds -= 1500
print(account.funds)
The output is:
1000
-500
Let me know if you can recreate this on your end.