tags:

views:

495

answers:

2

I want to do something simple and straightforward, like min(5,10), or Math.max(4,7). Are there functions to this effect in Ruby?

+8  A: 

You can do [5,10].min, or [4,7].max.

EDIT: They come from the Enumerable module, so anything that includes Enumerable will have those methods available.

theIV
+2  A: 

You can use [5,10].min or [4,7].max The method of arrays

Diego Dias