min and minBy

The min function returns the smallest value of the list. The minBy function takes a lambda expression with one value. We can pass a negative value to the lambda expression to get the largest value in the list, as follows:

println("Get min value ${numbers.min()}")
println("Get max value ${numbers.minBy { -it }}")
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.96.94