From: Sebastian Hungerecker Date: 2008-03-21T07:24:40+09:00 Subject: Re: Delcaring a foo[] method Alex Wayne wrote: > I am trying to define a method that you call like this: > >   @obj.foo[123] That's two method calls: it calls foo() on @obj and then [](123) on the result of foo(). So you need to define foo to return something that responds to []. Like this: def foo() Object.new.instance_eval do def [](value) value*2 end self end end foo #=> # foo[6] #=> 12 HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826