From: "Brian Schröder" Date: 2005-06-03T02:22:01+09:00 Subject: Re: Implementing a Read-Only array On 02/06/05, Robert Klemme wrote: > Gavin Kistner wrote: > > On Jun 1, 2005, at 4:11 PM, Brian Schr�der wrote: > >>> Gavin Kistner wrote: > >>>>>> affectors = %w| << []= clear concat delete delete_at delete_if > >>>>>> fill flatten! insert map! pack pop push reject! replace reverse! > >>>>>> shift slice! sort! uniq! unshift | > >> > >> Though this means that you have to override all methods that can > >> change the array. I'd shurely forget something in this case. You > >> forgot e.g. #clear. Therefore I'd propose to explicitly delegate the > >> needed methods for the application because this is easier to control. > > > > But again, that way prevents users' convenience methods for Arrays/ > > Enumerables from being available. > > Yeah, I prefer the method to explicitely exclude mutators, too. The > reason being that IMHO there are more often non modifying convenience > methods defined on Array than modifying methods. > Just playing devils advocate here, but if you care about user added methods, the user may also add something that acts in effekt like class Array def mutate(i, v) self[i] = v end end which you certainly would like to remove. Though I have to disclaim that I personally would simply stick with a simple array and a note not to change its contents ;-) If it breaks, you will know it and if it does not it's also good. best regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/