Kotlin List methods – min() minBy() minWith()

In the tutorial, JavaSampleApproach will show how to use Kotlin List methods min(), minBy(), minWith().

I. Kotlin List methods – min() minBy() minWith()

1. min()

min() is used to return the smallest element of an Iterable. It will return ‘null’ if there are no element.
Method signature:

Practice:

2. minBy()

minBy() returns the first element having smallest value of the given function selector: (T) -> R or ‘null’ if there are no elements.
Method signature:

Practice:

3. minWith()

minWith() returns the first element having the smallest value according to the provided [comparator]
Method signature:

Practice:

II. Full Sourcecode

By JavaSampleApproach | January 11, 2018.


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*