From: "Christoffer Lernö" Date: 2007-03-16T21:26:28+09:00 Subject: Re: Anyone playing with higher order messaging in ruby? On Mar 16, 2007, at 13:21 , Robert Dober wrote: > On 3/16/07, Christoffer Lern� wrote: >> And another example: >> >> # A chat server where @clients = [connection1, connection2...] >> # message = "Hello" >> # sender = "Bob" >> >> # With normal each: >> packet = BroadcastChatPacket.new("#{sender} says: #{message}") >> @clients.each { |c| c.broadcast(packet) } >> >> # With each_do: >> @clients.each_do.broadcast(BroadcastChatPacket.new("#{sender} says: # >> {message}")) >> >> Eliminating the need for the temporary variable. >> > Do I understand correctly when I remark that a new BroadcastChatPacket > instance is created or each iterator call in #each_do.broadcast, No, each_do will only create BroadcastChatPacket once. /Christoffer