I have this code
tree match {
case EmptyNode =>
//do stuff with empty node
case Node(left, right, value) =>
//do stuff with node contents
}
However what if I want to update the value of a node? I tried doing value = newValue inside the case, but it doesn't seem to be allowed.
Structure of my trees/nodes:
sealed trait Tree
case class Node(var left: Tree, var right: Tree, var value: String) extends Tree
case object EmptyNode extends Tree
You can reference the actual node with
@
notation: