Scala Iterator min() method with example
The min() method belongs to the concrete value members of the class AbstractIterator. It is defined in the classes IterableOnceOps. It is utilized to find the smallest element.
Method Definition : def min[B >: A](implicit ord: math.Ordering[B]): A
Where, B is the type over which the ordering is defined and ord is an ordering to be used for comparing elements.
Return Type : It returns the smallest element of the collection stated with respect to the ordering ord.
Example #1:
// Scala program of min() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Declaring an iterator val iter = Iterator(50, 60, 11, 90, 21) // Applying min method val iter1 = iter.min // Displays output println(iter1) } } |
11
Here, the smallest element of the stated collection is returned.
Example #2:
// Scala program of min() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Declaring an iterator val iter = Iterator(2.1, 3.3, 1.1, 4.6) // Applying min method val iter1 = iter.min // Displays output println(iter1) } } |
1.1
Recommended Posts:
- Scala Iterator next() method with example
- Scala Iterator max() method with example
- Scala Iterator sum() method with example
- Scala Iterator seq() method with example
- Scala Iterator map() method with example
- Scala Map iterator method with example
- Scala Iterator take() method with example
- Scala Iterator zip() method with example
- Scala Iterator toBuffer() method with example
- Scala Iterator toIterable() method with example
- Scala Iterator mkString() method with example
- Scala Iterator toList() method with example
- Scala Iterator duplicate() method with example
- Scala Iterator forall() method with example
- Scala Iterator exists() method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



