A
Aldric Giacomoni
"I hear and I forget; I see and I remember; I do and I understand."
Wouldn't it be nice if it were that simple - clearly they did not know
about the subtle art of debugging.
So, I'm trying to hack at the math module.
Expected:=> sqrt(2)
Actual result, mileage does not vary:=> 1.4142135623731
require 'mathn'
module Math
alias ld_sqrt :sqrt
def sqrt x
result = old_sqrt x
if result.is_a? Float
"sqrt(#{x})"
else
result
end
end
end
puts Math.sqrt(2)
I had originally not attempted an alias, I just did "result = super x"
but it didn't really amount to much, either.
Where am I thinking about this wrong?
Wouldn't it be nice if it were that simple - clearly they did not know
about the subtle art of debugging.
So, I'm trying to hack at the math module.
Expected:=> sqrt(2)
Actual result, mileage does not vary:=> 1.4142135623731
require 'mathn'
module Math
alias ld_sqrt :sqrt
def sqrt x
result = old_sqrt x
if result.is_a? Float
"sqrt(#{x})"
else
result
end
end
end
puts Math.sqrt(2)
I had originally not attempted an alias, I just did "result = super x"
but it didn't really amount to much, either.
Where am I thinking about this wrong?