Why is sqrt() not a method on Float?

Posted by KaptajnKold on Stack Overflow See other posts from Stack Overflow or by KaptajnKold
Published on 2010-05-16T16:34:04Z Indexed on 2010/05/16 16:40 UTC
Read the original article Hit count: 237

Filed under:
|

In Ruby everything is an object. That's why I don't understand why we have the Math module. It seems to me that most (all?) of the functions in the Math module should have been methods on the numeric types like Integer, Float and so on.

E.g. instead of

Math.sqrt(5)

it would make more sense to have

5.sqrt

The same goes for sin, cos, tan, log10 and so on.

Does anyone know why all these functions ended up in the Math module?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about oop