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
abstract class Tree | |
case class Leaf(value: String) extends Tree | |
case class Branch(left: Tree, right: Tree) extends Tree | |
def walk(t: Tree): Unit = | |
t match { | |
case Branch(Stub, _) => println("branch-with-stub-on-the-left") | |
case Branch(left, right) => { | |
println("\nbranch-leaf") | |
walk(left) |