Yes. But he does state it is a read only not modified array. My understanding is. 'Array' is an NSMutableArray, I was merely suggesting using freeze to throw that exception just in case there maybe some code attempting to write/modify.
Mutex is the way to go but it also has an overhead. Terry Moore On 20/10/2011, at 4:28 AM, Matt Aimonetti <mattaimone...@gmail.com> wrote: > 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 _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel