📜  coerceAtMost - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:56.595000             🧑  作者: Mango

代码示例1
//Ensures that this value is not greater than the specified maximumValue
//coerceAtMost is recommended instead of Math.Min or Math.Max

//Int Example
println(10.coerceAtMost(5)) // prints 5
println(10.coerceAtMost(20)) // prints 10
println(10.coerceAtMost(30)) // prints 10

//enum example
println(DayOfWeek.FRIDAY.coerceAtMost(DayOfWeek.SATURDAY)) // FRIDAY
println(DayOfWeek.FRIDAY.coerceAtMost(DayOfWeek.WEDNESDAY)) // WEDNESDAY