From: Gary Wright Date: 2007-03-01T05:35:17+09:00 Subject: Re: Overload [] operator and use a block ? On Feb 28, 2007, at 3:21 PM, St�phane Wirtel wrote: > class Test > def []( x ) > # to do something here > yield if block_given? > end > end > > t = Test.new > t['string'] do > puts 'this is a test' > end Not in Ruby 1.8.x but your example works just fine in Ruby 1.9. The problem isn't with the definition of the method but in the way the 1.8.x parser deals with the trailing block on the method call. The parser has been changed to recognize the block in 1.9. Gary Wright