Monday, 9 September 2013

scala pattern matching nested cases

scala pattern matching nested cases

I try to match after some case applied. Kind of nested cases/matches:
val x1 = 1
val str = x1 match { // scala.MatchError: 1 (of class java.lang.Integer)
case x if(x > 1) => "x"+x match {case "x1" => "yes"}
}
println (str)
It fails with scala.MatchError exception.
Is it possible? It seems I've seen something similar.

No comments:

Post a Comment