From: James Gray Date: 2008-05-24T03:56:44+09:00 Subject: Re: Ruby observer module On May 23, 2008, at 1:49 PM, S2 wrote: > I am reading Design Patterns in Ruby, and was looking at the code of > the > observer module. On line 184, in notify_observers, there is a loop > on all > registered observers: > > for i in @observer_peers.dup > i.update(*arg) > end > > Why is there a "dup" on the array? Is that really necessary? Isn't > this a > waste of memory? I am sure there is a really good explanation, but I > don't > grasp it. I'm totally guessing here, but could it be to keep the list from changing while it iterates? James Edward Gray II