From: Ross Bamford Date: 2005-12-20T06:12:48+09:00 Subject: Re: is there a way to use a proc like a method? On Mon, 19 Dec 2005 20:50:44 -0000, hochherz wrote: > is there a way to use a proc like a method? > > like: > > class A > def initialize > @av=10; > end > def do(mproc) > mproc.call(); > end > def rt() > @av; > end > end > > > a=proc{@av=111} #something different > b=A.new > b.do(a) > b.rt #return -> 111 > > is it possible by makeing subclass of proc to do this? Maybe use: def do(mproc) instance_eval &mproc end instead of 'call' -- Ross Bamford - rosco@roscopeco.remove.co.uk