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
AnyGenerator { | |
defer { | |
iteration += 1 | |
} | |
// こっちはダメ | |
guard iteration > 3 else { | |
return iteration | |
} | |
return nil | |
} |
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
class HTMLElement { | |
let name: String | |
let text: String? | |
// プロパティでasHTMLへのstrong参照を持っている | |
lazy var asHTML: Void -> String = { // nameとtextを使いたいからlazy | |
// Closure内でselfのプロパティをキャプチャしている | |
if let text = self.text { | |
return "<\(self.name)>\(text)</\(self.name)>" |