Skip to content

Instantly share code, notes, and snippets.

@kellegous
Created December 5, 2015 00:04
Show Gist options
  • Select an option

  • Save kellegous/c93a59b4fb76acd69ffc to your computer and use it in GitHub Desktop.

Select an option

Save kellegous/c93a59b4fb76acd69ffc to your computer and use it in GitHub Desktop.
class Bucket {
let id : Int
init(id: Int) {
print("\(id) is upon us.")
self.id = id
}
deinit {
print("\(id) has left the building.")
}
func description() -> String {
return "I am \(id)"
}
}
func thereBeBuckets() {
let bb = Bucket(id: 1)
print(bb.description())
}
func thereBeBucketsLifted() -> (() -> Void) {
let bb = Bucket(id: 2)
func sub() {
let bc = Bucket(id: 3)
print(bc.description())
print(bb.description())
}
return sub
}
let ba = Bucket(id: 0)
let fn = thereBeBucketsLifted()
thereBeBuckets()
0 is upon us.
2 is upon us.
1 is upon us.
I am 1
1 has left the building.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment