.limit( x, y )

If this number is smaller then 'x', then 'x' is returned. If this number is larger then 'y', then 'y' is return. Otherwise this number is returned.

The order of the 'x' and 'y' values does not matter.

// n is set to 9
n = 10.limit( 3, 9 )

// sets z to a random number, limited between x and y
z = rand()

x = 39
y = 56
z = z.limit( x, y )

This is essentially a compact version of calling both 'min' and 'max' methods on this object.

See also

min - max - wrap