Scala SortedMap min() method with example
Last Updated :
02 Nov, 2019
The min() method is utilized to find the smallest element of the SortedMap.
Method Definition: def min: (A, B)
Return Type: It returns the smallest element of the SortedMap.
Example #1:
import scala.collection.immutable.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "cs" - > 2 )
val result = m 1 .min
println(result)
}
}
|
As we can see in above example cs is the smallest element in the SortedMap.
Example #2:
import scala.collection.immutable.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "for" - > 6 )
val result = m 1 .min
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...