Created
June 1, 2019 21:48
-
-
Save krzyzanowskim/10a509b26e69509dc4293ebb37bc6e87 to your computer and use it in GitHub Desktop.
didSet is called on each update of Array
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 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