Skip to content

Instantly share code, notes, and snippets.

@krzyzanowskim
Created June 1, 2019 21:48
Show Gist options
  • Save krzyzanowskim/10a509b26e69509dc4293ebb37bc6e87 to your computer and use it in GitHub Desktop.
Save krzyzanowskim/10a509b26e69509dc4293ebb37bc6e87 to your computer and use it in GitHub Desktop.
didSet is called on each update of Array
class Node: CustomStringConvertible {
let title: String
var parent: Node?
var children: [Node] = [] {
didSet {
children.forEach({ $0.parent = self })
}
}
var description: String {
return title
}
init(_ title: String) {
self.title = title
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment