Skip to content

Instantly share code, notes, and snippets.

@macrael
Created January 19, 2017 23:24
Show Gist options
  • Select an option

  • Save macrael/615987684c90635c77f3df04c45a0f99 to your computer and use it in GitHub Desktop.

Select an option

Save macrael/615987684c90635c77f3df04c45a0f99 to your computer and use it in GitHub Desktop.
class FooClass {
var name: String = "" {
didSet(newName) {
print("SET")
print(newName)
}
}
func changeAName(inout theProp: String) {
theProp = "jazzhands" # Changes the value of name but doesn't call the setter
}
func chagngeit() {
self.changeAName(&self.name)
}
}
let f = FooClass()
f.name = "jazzersize" # calls the setter correctly
f.name # "jassersize"
f.chagngeit()
f.name # "jazzhands"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment