Created
March 12, 2016 05:09
-
-
Save niwatako/59bd4d94841aa84fee57 to your computer and use it in GitHub Desktop.
inline lazy var #catchswift #cocoa_kansai #CodePiece
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 MyClass { | |
| lazy var calculate1: () -> Int = self.calculate | |
| lazy var calculate2: () -> Int = { | |
| self.calculate() | |
| }() | |
| } | |
| // calculate1 は 型 () -> Int より、calculate2と同じ、クロージャーが代入される。見た目はselfをキャプチャしていないかのように見えてしまうけど、calculate2がselfに循環参照を起こすのと同じように、calculate1も循環参照を生む。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment