It's very common when writing game code to want to express the idea that this variable saturates at a certain value, for example:
Code: Select all
this.x += Time.deltaTime;
if (this.X > maxValue) {
this.X = maxValue;
}
Now you see how my brain likes to think in terms of the "maximum value" this variable is allowed to have, so trying to get more concise code, I reach for the aptly named....
Code: Select all
this.x = Min(this.x + Time.deltaTime, maxValue)
Min,

yes, I have to use min to set a max value and max to set a min value. This breaks my brain, I've known for years, and I still have to stop and think about it every time.
I give up, I'm throwing the towel, I have defined these functions and will be using them from now on
Code: Select all
float AtMost(float a, float b) => Min(a, b);
float AtLeast(float a, float b) => Max(a, b);