From: Jamis Buck Date: 2004-08-24T10:32:25+09:00 Subject: Re: *with* block? Zach Dennis wrote: > I am looking for a structure like: > > my_obj = boxWidget.new > with my_obj do > x = 0 > y = 10 > width = 100 > height = 100 > end > > instead of having to say > > my_obj = boxWidget.new > my_obj.x = 0 > my_obj.y = 10 > my_obj.width = 100 > my_obj.height = 100 > > > > Can you do this already? If not....anyone support an RCR for it besides me? No such beast "out of the box," but there have been various discussions on the list about this feature. I believe one implementation presented was: class Object def with(obj, &block) obj.instance_eval &block end end with "hello" do puts length puts reverse end - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis "I use octal until I get to 8, and then I switch to decimal."