v Find Largest Key Or Value In A Map - Scala

Find Largest Key Or Value In 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 numbers = Map(1 -> 100, 
                  2 -> 200,
                  3 -> 300)

Find Largest Key

// Find largest key
numbers.max
(3,300)

Find Largest Value

// Find the largest value
numbers.valuesIterator.max
300