You're doing instance methods when you really want class methods.

Good time to google the difference if you don't already know.

Julian

Blog: http://random8.zenunit.com/
Twitter: http://twitter.com/random8r
Learn: http://sensei.zenunit.com/
New video up now at http://sensei.zenunit.com/ real fastcgi rails  
deploy process! Check it out now!


On 20/11/2009, at 4:27 AM, Aldric Giacomoni <aldric / trevoke.net> wrote:

> "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:
>>> Math.sqrt(2)
> => sqrt(2)
> Actual result, mileage does not vary:
>>> Math.sqrt(2)
> => 1.4142135623731
>
> require 'mathn'
> module Math
>  alias :old_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?
> -- 
> Posted via http://www.ruby-forum.com/.
>