I wrote the following code, which keeps
within the range
x = [a, [x, b].min].max
As it is quiet a basic and useful function, I was wondering if there is a native method to do that in ruby.
As there is apparently no method to do it, what would be the shortest/more readable way to do it? I found
x = [a,x,b].sort
so far, but am not sure if it is more readable.