manual_clamp
Finds a value kept between two constant bounds by hand instead of with clamp.
Category complexity, warn by default.
#import "Basic";
main :: () {
volume := 140;
volume = max(0, min(100, volume));
print("%\n", volume);
}warning[manual_clamp]: `volume` is kept between `0` and `100` by hand
--> example.jai:5:14
|
5 | volume = max(0, min(100, volume));
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: write `clamp(volume, 0, 100)`
|
5 ~ volume = clamp(volume, 0, 100);
|
= note: `manual_clamp` is `warn` by default#import "Basic";
main :: () {
volume := 140;
volume = clamp(volume, 0, 100);
print("%\n", volume);
}Numbers with constant bounds, the lower not above the upper (a swapped pair is min_max's).