Skip to content

Instantly share code, notes, and snippets.

@felixvisee
Created June 12, 2015 16:01
Show Gist options
  • Save felixvisee/d0860a01efc93476ec3a to your computer and use it in GitHub Desktop.
Save felixvisee/d0860a01efc93476ec3a to your computer and use it in GitHub Desktop.
struct Value {
var property: Int = 0
mutating func change() {
property++
}
func changed() -> Value {
var copy = self
copy.property++
return copy
}
}
var a = Value()
a.property // 0
a.change()
a.property // 1
a = a.changed()
a.property // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment