Map[String, String]
Scalaに があると想像してください。
マップ内のキーと値のペアの完全なセットと照合したいと考えています。
このようなことが可能になるはずです
val record = Map("amenity" -> "restaurant", "cuisine" -> "chinese", "name" -> "Golden Palace")
record match {
case Map("amenity" -> "restaurant", "cuisine" -> "chinese") => "a Chinese restaurant"
case Map("amenity" -> "restaurant", "cuisine" -> "italian") => "an Italian restaurant"
case Map("amenity" -> "restaurant") => "some other restaurant"
case _ => "something else entirely"
}
コンパイラはthulsyに文句を言います:
error: value Map is not a case class constructor, nor does it have an unapply/unapplySeq method
でのキーと値の組み合わせのパターン マッチの現在の最良の方法は何Map
ですか?