From: Jano Svitok Date: 2007-08-18T03:25:29+09:00 Subject: Re: method access to the enclosing method's locals? 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? Hi, you may try something using 1. blocks, 2. passing actual binding, 3. there was something called binding of caller, but I'm not sure whether it still works, as it was based on a bug in ruby implementation. Maybe if you post a bit higher perspective on your problem somebody would come up with a solution... J.