Everything in Ruby is an object, this is the reason why I do not understand why we have a math module It seems that most of the work in mathematical modules (all?) Should be ways of integer, float, and similar numerical types.
Example instead of
Math.sqrt (5)
5 .sqrt
same sin
, cos
, tan
, log10
and Goes for
Does anyone know why all these tasks have ended in the Math module?
I do not know the early history of Ruby, but I think the math module C & lt; Math.h> Header It's a weird duck in the Ruby Standard Library.
But, it's Ruby! So you can always pull out monkey patching!
Class Float Def sqrt; Math.sqrt (self); End df sin; Mathematics.pap (self); Enddef cos; Mathematics. Because (self); And Def Tan; Math.tan (self); End deaf log 10; Math.log10 (self); End End
Comments
Post a Comment