Yes, it should work because (almost) everything in Scala is an expression, and each expression can be used as a pattern match.
In this case, a pattern match is an expression, so it can be used with another chained match. But he does not like the compiler.
Providing the compiler with a small hint of parentheses helps:
case class ADT(value: Int) val a = ADT(5) (a match { case ADT(a) if a > 4 => ADT(a * 3) case ADT(a) => ADT(a + 1) }) match { case ADT(a) if a > 13 => println(a) case _ => {} }
michael.kebe
source share