binding()
public
Returns the binding associated with
prc. Note that Kernel#eval accepts
either a Proc or a Binding object as its second parameter.
def fred(param)
proc {}
end
b = fred(99)
eval("param", b.binding)
Show source
static VALUE
proc_binding(VALUE self)
{
rb_proc_t *proc;
VALUE bindval = binding_alloc(rb_cBinding);
rb_binding_t *bind;
GetProcPtr(self, proc);
GetBindingPtr(bindval, bind);
if (TYPE(proc->block.iseq) == T_NODE) {
rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
}
bind->env = proc->envval;
return bindval;
}