I have a calculation that may return a negative value. In that case, I want to limit the lowest return value to 0.
a - b
> -1
To get the desired result, I know I can place that calculation in an array with 0
and retrieve the highest value:
[0, a - b].max
> 0
I thought that there was a method on Integer that could do this (I was thinking of #floor
but that does something different.) I've taken a look at the documentation but I can't find a method that does what I want and I feel that I must have missed something. Is there a method that returns the result I want? Is there a better way than the one I've suggested?