From: James French Date: 2009-03-25T20:02:33+09:00 Subject: Re: appending an array to a frozen array Ah, I understand - thanks. My next question is - is it possible to prevent this? ________________________________________ From: lasitha [lasitha.ranatunga@gmail.com] Sent: 25 March 2009 10:48 To: ruby-talk ML Subject: Re: appending an array to a frozen array On Wed, Mar 25, 2009 at 4:00 PM, James French wrote: > Morning all, > > @dependencies.freeze > @dependencies += ["blah", "blah"] > > does not error out due to modifying a frozen array (1.8.7 p72). > [...] += creates a new array and assigns it to @dependencies. The original array remains frozen but @dependencies no longer refers to it. To illustrate: $: irb 01> a = b = [1, 2] --> [1, 2] 02> a.freeze --> [1, 2] 03> b.frozen? --> true 04> b += [3, 4] --> [1, 2, 3, 4] 05> a.frozen? --> true solidarity, lasitha