枚举值在匹配/情况表达式中似乎无法使用。这是在工作表中发生的情况。
object EnumType extends Enumeration {
type EnumType = Value
val a, b = Value
}
import EnumType._
val x: EnumType = b //> x : ... .EnumType.EnumType = b
x match {
case a => "a"
case b => "b"
} //> res0: String = a
if (x == a) "a" else "b" //> res1: String = b
发生了什么事?谢谢。
case
永远不会匹配,对吧? - Randall Schulz