From: Gregory Brown Date: 2007-01-22T05:01:22+09:00 Subject: Re: inspect...and modify a proc object? On 1/21/07, Gregory Brown wrote: > On 1/21/07, kelly wrote: > > myproc.methods returns the methods of the proc object itself. The proc > > object, I guess, is a container for the original block. I'm interested > > in the contents of the original block. > > > > Any suggestions for exposing details about the original block? > > this seems just plain evil, so please think about why you'd ever do > it, and also, look for better solutions! :) Actually, sorry that doesn't do the trick. It'll give you the enclosing scope, but not access to the block local scope. >> b = lambda { |x| n=3; x + a } => # >> b.eval_with_binding('n') NameError: undefined local variable or method `n' for main:Object from (irb):10 from (irb):10 >> b[10] => 20 >> b.eval_with_binding('n') NameError: undefined local variable or method `n' for main:Object from (irb):10 from (irb):10