Scala List min() method with example
Last Updated :
26 Jul, 2019
The min() method is utilized to find the smallest element of all the elements in the stated list.
Method Definition: def min[B >: A](implicit ord: math.Ordering[B]): A
Return Type: It returns the smallest of all the elements in the stated list.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 2 , 3 )
val result = m 1 .min
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 5 , 12 , 3 , 13 )
val result = m 1 .min
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...