From: Jim Freeze Date: 2003-05-09T00:03:39+09:00 Subject: Re: [Q] Block passing: obj.new(){block} On Thursday, 8 May 2003 at 22:58:25 +0900, ts wrote: > >>>>> "P" == Peter Schrammel writes: > > P> t=Test.new("foo"){set=89} > > pigeon% cat b.rb > #!/usr/bin/ruby > class Test > def initialize(foo, &block) > instance_eval(&block) > end > > def set=(myval) > @set=myval > end > def set > @set > end > end > > t=Test.new("foo") { self.set = 89 } You can also do: t=Test.new("foo") { @set = 89 } to save some typing. -- Jim Freeze ---------- ... and furthermore ... I don't like your trousers.