From: Joel VanderWerf Date: 2004-02-01T04:33:49+09:00 Subject: Re: cascading message sends Paul MG wrote: > In Smalltalk, which Ruby is much like in some ways, you can 'cascade' > message sends. That is, call a bunch of methods on the same object > without naming it explicitly over and over. Eg: > > aCollection add: 5; add: 7; add: 'foo' ! > > calls 'add' on 'aCollection' 3 times, sending 5, 7, and 'foo'. > > Does Ruby have this syntax? Here's one option, not as elegant: x=[] x.instance_eval do push 1 push 2 push 3 end p x Inside the do...end block, "self" is x.