Skip to content

Instantly share code, notes, and snippets.

@Julioacarrettoni
Created August 17, 2017 14:22
Show Gist options
  • Save Julioacarrettoni/f4b2f03cc6b75b05b6975b22cadaa308 to your computer and use it in GitHub Desktop.
Save Julioacarrettoni/f4b2f03cc6b75b05b6975b22cadaa308 to your computer and use it in GitHub Desktop.
Testing a weak self issue with nested closures reported by @manuelmaly
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