On 15.01.2007 15:20, Gregory Seidman wrote:
> On Mon, Jan 15, 2007 at 10:52:37PM +0900, Juozas Gaigalas wrote:
>> I'm looking for a simple and short solution/library that does this:
>>
>> a = []
>>
>> def a.modified
>> puts "Array a changed"
>> end
>>
>> a << 'x'
>> puts a
>> a[0] = 'y'
>> puts a
>>
>> ----OUTPUT----
>> Array a changed
>> x
>> Array a changed
>> y
> 
> You can sort of do this, but an object does not know what variable(s) it is
> assigned to, so you will never be able to get the "Array a changed" message
> from it directly. Try the following, however:
> 
> module ArrayWatch
>   def is_modified?
>     @modified
>   end
...

Alternative approach would be to use Delegator to wrap an Array instance.

OP, what are you trying to achieve?  What is the problem you are trying 
to solve?

Kind regards

	robert