That's really cool!

Do you know how it does it?  Does the 'require' set a variable or 
something?  I ask because I want to make a Math::Polynomial class that can 
be used both for real and complex polynomials.

Thanks.


On Wed, Feb 05, 2003 at 04:46:29PM +0900, Kent Dahl wrote:
> Daniel Carrera wrote:
> > 
> > What do people think of making "Math.sqrt(-1)" return "Complex(0,1)"?
> 
> It already does.
> 
> [kentda@v052a kentda]$ irb          
> irb(main):001:0> Math.sqrt(-1)
> ArgumentError: square root for negative number
>         from (irb):1:in `sqrt'
>         from (irb):1
> irb(main):002:0> require 'complex'
> true
> irb(main):003:0> Math.sqrt(-1)
> Complex(0, 1.0)
> irb(main):004:0> 
> 
> This little trinket seemed to catch the attention when I tried it at a
> small Ruby course last year.
> 
> -- 
> (\[ Kent Dahl ]/)_    _~_    __[ http://www.stud.ntnu.no/~kentda/ ]___/~
>  ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 5. year  )
> ( \__\_?|?_/__/ ) _)Industrial economics and technological management(
>  \____/_?_\____/ (____engineering.discipline_=_Computer::Technology___)
> 

-- 
Daniel Carrera
Graduate Teaching Assistant.  Math Dept.
University of Maryland.  (301) 405-5137