Wednesday, 27 May 2009

Scala - Alternative to instanceOf

Use a match...case statement:

Is tree1 an instance of Node[T]?

tree1 match {
case tree1: Node[T] => true
case _ => false
}

No comments:

Post a comment