Hi,
In message "[ruby-talk:18977] "Bang" versions of numerical methods on non-immediate values [was: Numbers classes.. Rational number? ]"
on 01/08/02, Kent Dahl <kentda / stud.ntnu.no> writes:
|Summary: I want methods add!, sub!, div! and mul! for all numeric
|objects.
immediate values (fixnums and symbols) cannot be modified from method,
so you cannot implement any bang method for fixnums. You need
assignment to alter value in a variable.
You want
| a = b = 1
| a.add!(1) # a==2 and b==1, due to immediate values
but since 1 is a fixnum, thus the value of a cannot be changed.
Considering this fact and that fixnums are most common numeric, bang
method for numeric is not a good idea.
matz.