Daniel Finnie
1/9/2007 1:34:00 AM
Why does everything have to be Math.<func>(num)? Isn't num.func more
object oriented-ish?
For example:
>> (Math.methods - Object.methods).select {|x| Math.method(x).arity ==
1}.each do |x|
?> Numeric.class_eval { ?> define_method(x.to_sym) {
Math.send(x.to_sym, self) } >> }
>> end
=> ["tan", "frexp", "sinh", "exp", "acos", "tanh", "log", "asin",
"acosh", "cos", "log10", "atan", "erf", "asinh", "sin", "sqrt", "cosh",
"erfc", "atanh"]
>> *5.sqrt*
=> 2.23606797749979
>> *Math.sqrt(5)*
=> 2.23606797749979
>>
I think the first one, 5.sqrt, looks much better than Math.sqrt(5).
Thanks,
Dan