Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adamnemecek/cdcefa559bae17ea2b13a1e446cef978 to your computer and use it in GitHub Desktop.
Save adamnemecek/cdcefa559bae17ea2b13a1e446cef978 to your computer and use it in GitHub Desktop.
import Foundation
struct Test {
var value: Int = 0
var f: (Int, Int) -> Int {
mutating get {
var this = self
print("in getter value: \(this.value)")
return { _ in
this.value = 10
print("in closure value: \(this.value)")
return 100
}
}
}
}
var h = Test()
print("before getter h: \(h)")
let f = h.f(30,31)
print("f: \(f)")
print("after getter h: \(h)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment