Search A Map

If you want to learn more, check out Scala Cookbook and Programming in Scala.

Create A Map

// Create an immutable map with three key value pairs
val staff = Map("CEO" -> "Judith Jackson",
                "CFO" -> "Sally Shields",
                "CTO" -> "Steven Miller")

Test If Key Exists

// Test if key exists
staff.contains("CTO")
true

Test If Value Exists

// Test is any value exists which contains part of a string
staff.valuesIterator.exists(_.contains("Miller"))
true