Reputation: 3454
I have a class that looks like this:
class ContactsHolder {
static let name = "joe"
}
and from another class I can call it like so:
println(ContactsHolder.name)
My question is how do I set that variable to something else?
I tried:
ContactsHolder.name = "bob"
and get Cannot assign to the result of this expression
Am I going about this completely wrong or what do I need to do??
Upvotes: 0
Views: 252
Reputation: 70094
With let
you declare a constant that can't be modified.
You can use a variable instead:
class ContactsHolder {
static var name = "joe"
}
ContactsHolder.name = "mike"
println(ContactsHolder.name) // prints "mike"
Upvotes: 3