Forum: Ruby Re: Why is there a seperate Math class?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
825738339f48c5b8b2a72c02caf3d91c?d=identicon&s=25 Gavin Kistner (Guest)
on 2007-01-09 21:38
(Received via mailing list)
From: Ilmari Heikkinen [mailto:ilmari.heikkinen@gmail.com]
> On 1/9/07, Phrogz <gavin@refinery.com> wrote:
> > 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)

Good argument. In fact, one of them is there already:
  require 'matrix'
  Vector[3,4].r    #=> 5.0
94cc3e46cfc5bc361e409e2e884ecfa4?d=identicon&s=25 Drew Olson (dfg59)
on 2007-01-09 23:01
> Good argument. In fact, one of them is there already:
>   require 'matrix'
>   Vector[3,4].r    #=> 5.0

Gavin -

Just wanted to point out to you that each of your replies is creating a
new thread. You might want to reply with the same subject to avoid this.
Just thought you'd like to know.

-Drew
This topic is locked and can not be replied to.