From: Rick DeNatale Date: 2006-10-26T08:53:34+09:00 Subject: Re: Pass block instead of here document? On 10/25/06, Morton Goldberg wrote: > I have a situation where I want to send many messages, one after the > other, to single object. Instead of writing, say, > > foo.eat burger, fries > foo.drink beer > foo.be_merry > > I want to be able to write something like: > > foo.perform { eat burger, fries; drink beer; be_merry } Others have already answered your question, but the above syntax reminds me of one thing in Smalltalk which I miss a bit in Ruby. Smalltalk has very little syntax, but one piece is the use of semicolons to do what Smalltalk calls message cascading. As in Ruby each method in Smalltalk returns a value and if you write something like: obj msg1 msg2 This sends msg1 to obj, and then sends msg2 to the value returned by obj msg1, much like the equivalent ruby syntax: obj.msg1.msg2 But in Smalltalk if you write: obj msg1;msg2 the object referenced by obj is sent msg1 and then msg2 in sequence, regardless of the value returned by obj msg1. Since Ruby doesn' t have such syntax, it's probably not missed much, but since Smalltalk did it was pretty heavily used. Smalltalk also had a method in Object called yourself which returned the receiver which is commonly used as the last message in such a cascade on the right hand side of an assignment. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/