Last active
March 13, 2017 10:17
-
-
Save shabib87/305325781d76f991b7376ec7cc916915 to your computer and use it in GitHub Desktop.
In support to blog post
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 { | |
... | |
lazy var asHTML: () -> String = { [weak self] in | |
guard let htmlElement = self else { return "" } | |
return "<\(htmlElement.name)>\(htmlElement.text)</\(htmlElement.name)>" | |
} | |
... | |
} | |
var paragraph: HTMLElement? = HTMLElement(name: "p", text: "hello, world") | |
paragraph?.asHTML() | |
paragraph = nil | |
// Output: | |
// HTMLElement p is being deinitialized | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment