The coerceAtLeast(minValue) function

This function takes one parameter: a minimum value. It returns the target value if it is greater than or equal to minValue, otherwise it returns minValue. The coerceAtLeast function makes sure that the returned value is at least as great as the value that is mentioned in minValue:

val i = 2.coerceAtLeast(4)
println(i)

 Here, the answer will be 4, because minValue is greater than the target value, 2.

..................Content has been hidden....................

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