Min, max for Fixnum?

Did I understand it right that there are no operators/functions
predefined in Ruby for getting the minimum and maximum for two Fixnum?

I.e.

def min(a,b)
a < b ? a : b
end

Or did I just overlook something?

Ronald

Hi Ronald,

Ronald F. wrote:

Did I understand it right that there are no operators/functions
predefined in Ruby for getting the minimum and maximum for two Fixnum?

I.e.

def min(a,b)
a < b ? a : b
end

Or did I just overlook something?

Ronald

I think that min and max are very general, so they don’t have to be
limited to Fixnum.

How about [a, b].min or [a, b].max?

[1, 2].min #=> 1

Sam

On 08/08/06, Ronald F. [email protected] wrote:

Ronald


Ronald F. [email protected]
Posted via http://www.newsoffice.de/

There is Enumerable#min. [10,5,3,7].min will return 3.

Farrel

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs