Title: Find Largest Key Or Value In A Map
Slug: find_largest_key_or_value_in_a_map
Summary: Find Largest Key Or Value In A Map Using Scala.
Date: 2017-04-03 12:00
Category: Scala
Tags: Basics
Authors: Chris Albon
If you want to learn more, check out Scala Cookbook and Programming in Scala.
In [1]:
// Create an immutable map with three key value pairs
val numbers = Map(1 -> 100,
2 -> 200,
3 -> 300)
In [2]:
// Find largest key
numbers.max
Out[2]:
In [5]:
// Find the largest value
numbers.valuesIterator.max
Out[5]: