From: david karapetyan Date: 2007-08-18T16:17:17+09:00 Subject: Re: method access to the enclosing method's locals? ------=_Part_111226_25985758.1187421442921 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline The general concept involved is that of a closure and it is certainly possible to define closures in ruby and at some point or another someone pointed out a way of turning closures into methods I don't remember how though. On 8/17/07, Larry Kluger wrote: > > > Hi, > > How can a method gain access to the enclosing method's locals? > > def go2(arg) > def hi > puts "Hi #{arg}!" > end > > a={:h => :hi} > send(a[:h]) > end > > go2 'Larry' ==>> NameError: undefined local variable or method `arg' for > main:Object > > In go2, is there a clean way for the hi method to have access to the > arg local? > > Thanks! > > Larry > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_111226_25985758.1187421442921--