Created
August 17, 2017 14:22
-
-
Save Julioacarrettoni/f4b2f03cc6b75b05b6975b22cadaa308 to your computer and use it in GitHub Desktop.
Testing a weak self issue with nested closures reported by @manuelmaly
This file contains hidden or 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 Foundation | |
//https://twitter.com/manuelmaly/status/898141485228544000 | |
class Foo { | |
var y: Int = 8 | |
func bar() { | |
let b = { [weak self] in | |
let x = { | |
// self is nil here | |
return self?.y | |
}() | |
print(x) | |
} | |
return b() | |
} | |
} | |
let foo = Foo() | |
foo.bar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment