我有一张这样的地图:
val mealIdsMap: Map[String, String] =
Map (
"breakfast" -> "omelet",
"lunch" -> "steak",
"dinner" -> "salad"
)
然后我尝试在这样的匹配语句中使用它:
"omelet" match
{
case mealIdsMap("breakfast") => "Thank God"
}
我得到这个错误:
error: value mealIdsMap is not a case class constructor,
nor does it have an unapply/unapplySeq method
case mealIdsMap("breakfast") => "Thank God"
任何人都知道如何在匹配/案例声明中使用这样的地图?
非常感谢你的帮助。