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?
I don’t know the early history of Ruby, but I have a feeling the Math module was modelled after the C <math.h> header. It is an odd duck in the Ruby standard library though.
But, it’s Ruby! So you can always bust out the monkey patching!