y
06/05/2024, 3:34 PMfun MyTree?.addChildOrMakeRoot(child: MyTree) = if (this != null) { this.addChild(child) } else { this = child }
ephemient
06/05/2024, 3:36 PMthis
reference (or any other parameter for that matter)Sam
06/05/2024, 3:37 PMy
06/05/2024, 3:37 PMShawn
06/05/2024, 3:38 PMy
06/05/2024, 3:38 PMSam
06/05/2024, 3:38 PMy
06/05/2024, 3:39 PMephemient
06/05/2024, 3:39 PMclass MyTreeHolder(var root: MyTree?)
fun MyTreeHolder.addChildOrMakeRoot(child: MyTree) = root?.addChild(child) ?: run { root = child }
y
06/05/2024, 3:40 PM