The proper way to protect mutable objects is to use a mutex: http://www.ruby-doc.org/core-1.9.2/Mutex.html
- Matt Sent from my iPhone On Oct 19, 2011, at 8:06, Chuck Remes <cremes.devl...@mac.com> wrote: > > On Oct 19, 2011, at 12:41 AM, Terry Moore wrote: > >> If you're not wring/changing the array no problems. But to be safe use >> Object#freeze... >> >> Terry Moore >> >> On 19/10/2011, at 6:26 PM, Michael Johnston <lastobe...@mac.com> wrote: >> >>> Note, in my example I can also guarantee that none of the elements in b are >>> going to be changed (for example, an array of strings) > > Object#freeze is a terrible method. Supporting it requires an extra check > (#frozen?) in every method that tries to modify an object. This is why Ruby > is slow (certainly not the only reason, but decisions like this are > everywhere). > > :) > > Using #freeze won't save you but it will throw a RuntimeException if you try > to modify a frozen object. So it's really only good for pointing out that you > have a bug when you attempt to modify your immutable array. > > cr > > > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel