From: Gennady Date: 2003-05-09T01:11:24+09:00 Subject: Re: [Q] Block passing: obj.new(){block} If you want to do something "from within" an object (Test) why not to create a method in Test to do it. Or at lease a method to set var1, var3 and var54 altogether, as they are related anyway according to your code. In Ruby you can call object's methods from the block, that's no problem, even for initialize(). The problem you stepped onto is exactly the one I got into quite recently, when trying to use "method=" where Ruby interprets it as an assignment. Look for the recent thread "Method/Assignment ambiguity" where David Black presented an excellent explanation of inevitable problems were Ruby treating the case not the way it does now. Gennady. ----- Original Message ----- From: "Peter Schrammel" Newsgroups: comp.lang.ruby To: "ruby-talk ML" Sent: Thursday, May 08, 2003 8:32 AM Subject: Re: [Q] Block passing: obj.new(){block} > dblack@superlink.net wrote: > > Are you sure you wouldn't rather do: > > > > t = Test.new("foo") > > t.set(89) > > > > ? :-) > I know but I'd like to envoke a lot of methods in the object on creation > and thought of something like: > > t=Test.new(){var1=89,var3=89,var54="bar",onEvent("Click"){puts "You > clicked"},doSomething(1,2)} > > if I had to type self.xxx everytime or do t.varxxx=xxx I'd go nuts. > > Thanks for the replies so far > > >