From: "Christoffer Lernö" Date: 2007-03-16T20:30:45+09:00 Subject: Re: Anyone playing with higher order messaging in ruby? On Mar 14, 2007, at 23:48 , Benjohn Barnes wrote: > On 14 Mar 2007, at 19:57, Jason Roelofs wrote: > >> I haven't personally messed with this kind of stuff but code like >> this just >> makes me love Ruby even more. These types of, well DSL is really >> the best >> way to describe it, in such little code, makes Ruby such a blast >> to program >> in, and it's readable too! > > I think I must be getting too old, or I'm being a spring time > Scrouge... > > While it's neat, and it's cool Ruby can do that stuff, I've got to > ask "Why?". 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. /Christoffer