karelpeeters
12/05/2018, 2:44 PMfun IntRange.clamp(value: Int) = when {
value <= start -> start
value >= endInclusive -> endInclusive
else -> value
}marstran
12/05/2018, 2:52 PMcoerceAtLeast, coerceAtMost and coerceIn extensions on Int.
5.coerceIn(3..8) == 5
1.coerceIn(3..8) == 3
9.coerceIn(3..8) == 8karelpeeters
12/05/2018, 2:52 PMkarelpeeters
12/05/2018, 2:54 PMIntRange, that would have been a better place to put in I think.karelpeeters
12/05/2018, 3:02 PMPavlo Liapota
12/05/2018, 3:07 PMInt to get a new Int.
It is like you call filter or map on List to get another List.karelpeeters
12/05/2018, 3:08 PMPavlo Liapota
12/05/2018, 3:08 PMInt and Range is just nice structure to pass max and min value.karelpeeters
12/05/2018, 3:09 PM5.coerceIn(min, max) exists as well. That makes sense then.Hullaballoonatic
12/05/2018, 8:00 PMval foo: Int by RestrictedInt(-2..5), but I ran into issues when I first started writing it and shelved it when other work came up. but here is the start...karelpeeters
12/05/2018, 8:11 PMRestrictedInteger type and not all of it can be handled in the delegate? And what issue ls did you have?Hullaballoonatic
12/07/2018, 1:51 AMcompareTo() functions, I think?