From: Ilmari Heikkinen Date: 2007-01-09T22:12:24+09:00 Subject: Re: Why is there a seperate Math class? On 1/9/07, Phrogz wrote: > Daniel Finnie wrote: > > Why does everything have to be Math.(num)? Isn't num.func more > > object oriented-ish? > > In addition to the answers by others, what would you do for those math > functions whose arity isn't 1? > > Math.methods(false).select{ |n| Math.method(n).arity != 1 } > #=> ["hypot", "atan2", "ldexp"] > > All three take two arguments. While 3.hypot(4) *might* make > sense--given one leg of a right triangle, how long is the hypotenuse to > a given other leg--30.atan2( 40 ) makes little sense to me. hypot and atan are vector methods, so [30, 40].atan2, [3,4].hypot would be correct in the OO-sense, much like #max and #min are in Array and not Math (compare to e.g. JavaScript where there is Math.max and Math.min)