From: Markus Schirp Date: 2009-01-08T23:04:19+09:00 Subject: Re: How to return an unmodifiable but nor frozen array? You can return the array in a container, this container redirects all "read" operations to the array and does not redirect any "write" operations. class ArrayContainer def initialize(array) @array end def [](idx) @array[idx] end ... and so on end There is a specialized "delegate" class/module in ruby, using it should result in better performance than the solution in my ArrayContainer class. Mfg Markus On Thu, Jan 08, 2009 at 10:59:29PM +0900, LAMBEAU Bernard wrote: > Hi, > > Is there a mean to obtain an unmodifiable array which is not frozen? > > Assume you're implementing a directed graph with adjacency lists. A > node would like to expose it's outgoing edges (to let users enjoy its > enumerability for example) but you would like to ensure that this > array will not be modified. A solution would be to duplicate it and I > know that efficiency should not be my concern, but ... > > blambeau