Hi,
In message "Re: Things That Newcomers to Ruby Should Know (11/24/02)"
on 02/11/28, William Djaja Tjokroaminata <billtj / y.glue.umd.edu> writes:
|1) Why Fixnum is immutable (no Fixnum#succ!) while String is mutable
|(String#.succ! is provided)?
Numbers are immutable. Partially because of performance. Partially
because of Ruby's object model. In Ruby, objects are values, not
place holders, so that numbers themselves are naturally immutable.
|2) How do I know which objects/classes are mutable and
|immutable? (Answer: just read all the methods, and if no "!" methods are
|provided, it is immutable (?))
You don't have to care in general. If you can't change the state of
the object, it is immutable.
matz.