Created
September 12, 2014 19:07
-
-
Save sketchytech/673219e0ff2d88ebec86 to your computer and use it in GitHub Desktop.
#Swiftlang pub quiz: identify the file that will crash; bonus points if you can identify the most memory-friendly file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
var a:Foo? = Foo() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var b = a!.myFunc | |
a = nil | |
println(b()) | |
} | |
} | |
class Foo { | |
var bzz = "bzz" | |
lazy var myFunc:()->() = {print(self.bzz)} | |
var szz:String? { | |
return self.bzz | |
} | |
deinit { | |
println("deinit \(bzz)") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
var a:Foo? = Foo() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var b = a!.myFunc | |
a = nil | |
println(b()) | |
} | |
} | |
class Foo { | |
var bzz = "bzz" | |
lazy var myFunc:()->() = {[unowned self] in print(self.bzz)} | |
var szz:String? { | |
return self.bzz | |
} | |
deinit { | |
println("deinit \(bzz)") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
var a:Foo? = Foo() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var b = a!.myFunc | |
println(b()) | |
a = nil | |
} | |
} | |
class Foo { | |
var bzz = "bzz" | |
lazy var myFunc:()->() = {[unowned self] in print(self.bzz)} | |
var szz:String? { | |
return self.bzz | |
} | |
deinit { | |
println("deinit \(bzz)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment