From: Stefan Lang Date: 2005-07-29T20:37:09+09:00 Subject: Re: [newbie] make local var visible On Friday 29 July 2005 13:09, "Pe�a, Botp" wrote: > #>> I think you have 2 options here (maybe more, but these are > #the ones I > #>> can come up with as a newbie myself): > # > #four and counting... > # > #>> 1) pass foo as an argument. > #>> def mfoo(foo) ... end > #>> mfoo(foo) > #>> 2) make foo an instance-variable > #>> @foo = [..] > #>> def mfoo > #>> @foo.each... > #>> end > #> > #> or make it global (sigh): $foo > # > #or make a proc from the method > > > Hi Brian/Cristi/Wannes/Kroeger/Kero, and others, > > Yes. I've done what you have all suggested. Thank you. > But I was hoping for something "cleaner". Sorry. > > Can we request RCR for this? IMHO not necessary. Ruby already has what you want. You want a closure. foo=["a","b","c"] mfoo = lambda do � � foo.each do |f| � � � � p f � � end end mfoo.call -- Stefan