| Type Params | Return Type | Name and description |
|---|---|---|
<T extends Comparable> |
static T |
clamp(T self, T lower, T upper)Clamp a Comparable between a lower and upper bound |
<T extends Comparable> |
static T |
clamp(T self, Range<T> range)Clamp a Comparable between the lower and upper bound of a Range |
<T extends Comparable> |
static Range<T> |
clamp(Range<T> self, Range<T> range)Clamp a Range so that it falls within the bounds of another Range |
Clamp a Comparable between a lower and upper bound
assert 1.clamp( 3, 6 ) == 3
self - The Comparable to clamplower - The lower boundupper - The upper boundClamp a Comparable between the lower and upper bound of a Range
assert 1.clamp( 3..6 ) == 3
self - The Comparable to clamprange - The range to clamp toClamp a Range so that it falls within the bounds of another Range
assert (1..5).clamp( 3..6 ) == 3..5 assert (1..8).clamp( 3..6 ) == 3..6 assert (5..8).clamp( 3..6 ) == 5..6
self - The Range to clamprange - The Range to clamp to