From: "Marcel Molina Jr." Date: 2006-03-12T07:50:00+09:00 Subject: Re: from Python to Ruby in 10 seconds On Sun, Mar 12, 2006 at 07:41:20AM +0900, Logan Capaldo wrote: > >- With Python, strings and tuples are immutable (for > >speed, I believe). Does Ruby have immutables like this, > >or are most object mutable? > > > Strings are mutable, symbols, fixnums, floats and bignums are > immutable (among others) > For the most part if it makes sense that something should be > mutable, it is. I don't think that mutability is ever determined on > the basis of performance ( except for maybe symbols) > > Ruby doesn't have tuples (If these are the same tuples from ML, > etc.). Its array's are mutable. Any object can be made immutable by freezing it. >> array = %w(a b c d) => ["a", "b", "c", "d"] >> array << 'e' => ["a", "b", "c", "d", "e"] >> array.freeze >> array << 'f' TypeError: can't modify frozen array from (irb):3:in `<<' from (irb):3 marcel -- Marcel Molina Jr.