Skip to content

Instantly share code, notes, and snippets.

@oleksii-demedetskyi
Last active May 23, 2016 16:52
Show Gist options
  • Save oleksii-demedetskyi/aedb73c84410d05fdc079563642f1fcf to your computer and use it in GitHub Desktop.
Save oleksii-demedetskyi/aedb73c84410d05fdc079563642f1fcf to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
struct Test {
var value: Int = 0
mutating func incrementer() -> () -> () {
return {
self.value += 1
print(self)
}
}
}
var test = Test()
let increment = test.incrementer()
increment() // Test(value: 1)
increment() // Test(value: 2)
increment() // Test(value: 3)
increment() // Test(value: 4)
print(test) // Test(value: 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment