">定义为
val matches = {
case Match(x,y) => ...
case AnotherMatch(x,y,z) => ...
case x:YetAnother => ...
}
一个定义如下?
val match1 = {
case Match(x,y) => ...
}
val match2 = {
case AnotherMatch(x,y,z) => ...
}
val match3 = {
case x:YetAnother => ...
}
val matches = match1 orElse match2 orElse match3
如果匹配项为
Some(x: Int) if x > 0 => x
Some(x: Int) if x < 0 => -x
None => 0
因此,它在紧密循环中可能很重要,但通常不会。