I am trying to implement end nodes in my Binary Tree. I am wondering why this doesnt work:
// I thought that by adding Option, I can enter None as an allowed Node[T]. But neither p1 or p2 allows me to compile. How can I make this work?
class Node[T](text: String, one: Option[Node[T]], two: Node[T]) {
override def toString = "(" + one + ", " + two + ")"
}
object GenTest {
def main(args: Array[String]) {
val p1 = new Node("wait", "test", "test")
val p2 = new Node("odd", p1, p1)
println(p1)
}
}