OxL Reference

method i32.clamp

lo when the value is below it, hi when it is above, the value itself otherwise.

Example:

oxl✓ checked in CI
fn main() io {
  let a: i32 = 15
  print("{a.clamp(0, 10)} {(5 as i32).clamp(0, 10)}")
}
Output
10 5
pub(api) fn clamp(lo: i32, hi: i32) -> i32

Complexity. O(1).

Since. 1.0.0-beta

Parameters

NameType
loi32
hii32

Returns

i32

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/numbers.oxl:647

See also