Methods written in C and code blocks


(Igor Maximchuk) #1

It there a way to pass code block to method, written in C?

What I want is something like

require 'myext’
include Myext

Myclass.mymeth(56) do |x|
p x
end

···

myext.c

void Init_myext()
{
VALUE m = rb_define_module(“Myext”);
rb_define_module_function(m, “mymeth”, mymeth, 1); /* ? */
}

VALUE mymeth() /* ? */

How can I define mymeth and yield block inside of it?


(Shashank Date) #2

“Igor Maximchuk” xchookx@mail.ru wrote in message

It there a way to pass code block to method, written in C?

Search for “Block Decoux” on ruby-talk :wink: e.g. see:

[ruby-talk:21709] Re: Extension Question: Block Parameters


(Igor Maximchuk) #3

[ruby-talk:21709] Re: Extension Question: Block Parameters

Thank you!