max and maxBy

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

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

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