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?
views:
495answers:
2
+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
2009-08-31 20:56:28