From: S2 Date: 2008-05-24T03:49:57+09:00 Subject: Ruby observer module Hi, 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 also have another question: why does the subject (the notifying class) need to call "changed"? Wouldn't it be sufficient to call notify_observers? I mean, if I call notify_observers in the Subject class, doesn't that imply has something has changed? -- http://s2.diffuse.it/