The OR (pipe) operator seems to have a higher priority than the defender, so the following works:
def test(s: String, v: Boolean) = s match {
case "a" | "b" if v => true
case _ => false
}
assert(!test("a", false))
assert( test("a", true ))
assert(!test("b", false))
assert( test("b", true ))
source
share