Last active
December 22, 2015 00:19
-
-
Save externvoid/dd6ffbf53cf125126ca9 to your computer and use it in GitHub Desktop.
selfを参照するclosureメンバg(参照:http://stackoverflow.com/questions/29366270/closure-use-unresolved-identifier-self)
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
| class Bar { | |
| let someVal = 5 | |
| lazy var g:() -> String = { [unowned self] in | |
| // lazy: 次のエラー対策:error: use of unresolved identifier 'self' | |
| return String(self.someVal) | |
| } | |
| } | |
| var bar = Bar() | |
| print(bar.g()) // string "5" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment