Skip to content

Instantly share code, notes, and snippets.

@shabib87
Last active March 13, 2017 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shabib87/1461c799b769ec9630360883a1dacae7 to your computer and use it in GitHub Desktop.
Save shabib87/1461c799b769ec9630360883a1dacae7 to your computer and use it in GitHub Desktop.
In support to blog post
class HTMLElement {
let name: String
let text: String?
lazy var asHTML: () -> String = {
return "<\(self.name)>\(self.text)</\(self.name)>"
}
init(name: String, text: String? = nil) {
self.name = name
self.text = text
}
deinit {
print("HTMLElement \(name) is being deinitialized")
}
}
var paragraph: HTMLElement? = HTMLElement(name: "p", text: "hello, world")
paragraph?.asHTML()
paragraph = nil
// Output:
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment