Ruby observer module

I'm totally guessing here, but could it be to keep the list from changing while it iterates?

James Edward Gray II

···

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.