Dave Burt
5/30/2006 9:49:00 AM
> Schüle Daniel wrote:
>> Hello,
>>
>> dumb question, why is it forbidden to use
>> i=Fixnum.new
>> also Bignum.new
>> and Float.new
>> and Complex.new
As they say, no such thing as a stupid question, only stupid people.
Just kidding, it's actually a good question.
Further to Robert's explanation, Ruby doesn't want you to worry about
creating numbers. Think of them as values rather than objects, and just
use them.
This lets the classes do smart things behind the scenes like only making
one object per Integer, or automatically reducing Rational numbers.
For Complex numbers and Rational numbers, you can use Complex(r, i) and
Rational(n, d) instead of new.
Cheers,
Dave