From: Joel VanderWerf Date: 2004-08-27T05:20:00+09:00 Subject: Re: *with* block? Stefan Schmiedl wrote: > On Wed, 25 Aug 2004 21:07:01 +0900, > Mauricio Fern�ndez wrote: > >>On Wed, Aug 25, 2004 at 08:38:19PM +0900, Jim Weirich wrote: >> >>> with obj do |obj| >>> obj.x = 1 >>> obj.y = 2 >>> # ... >>> end >> >>hehe nice joke >> > > > but still useful, if you're programming with e.g. FXRuby, > as you can do something like the following (pseudo-code) > > with FX.create do |parent| > FX.create_child(parent) > end > > and avoid cluttering of local namespace. ...unless parent is already in the namespace. (Of course that may change in future ruby.) But it's a good point anyway. I often define #initialize to 'yield self if block_given?', but this version of #with is a way of getting that effect without touching initialize. Nice.