In the Ruby C source, you will see this in proc.c :
VALUE rb_block_proc(void) { return proc_new(rb_cProc, FALSE); }
and Proc.new does the following:
Creates a new Proc object bound to the current context. Proc::new can be called without a block only inside a method with an attached block, in which case this block is converted to a Proc object.
So you would do something like this:
VALUE p = rb_block_proc(); /* and then store `p` somewhere convenient */
and then later to call the / Proc block:
rb_funcall(p, rb_intern("call"), 0);
This rb_funcall is pretty much a version of C p.send(:call) .
source share