Saturday, July 5, 2008

Ruby 1.9 C API - Accepting Blocks


Executing the Block
rb_yield(Qnil);
Replace Qnil with the parameters you wish to pass to the block. The Result of the block is returned.
rb_block_given_p();
This function will tell you if a block was passed. Blocks are not counted as parameters so if your function only accepts a block then you need to specify 0 as the number of parameters.

No comments: