From: Daniel Berger Date: 2005-06-01T00:35:22+09:00 Subject: Passing a block to rb_funcall Hi all, I've seen some other threads on this subject, but none that quite answered my question. I'm trying to pass a variable number of arguments and a block to a class method from within an instance method. In Ruby it looks like this: # 'self' is a string def my_method(*args, &block) IO.foreach(self, *args, &block) end In C, I was trying something like this: static VALUE my_method(int argc, VALUE* argv, VALUE self){ VALUE rbSep, rbBlock; rb_scan_args(argc, argv, "01&", &rbSep, &rbBlock); return rb_funcall(rb_cIO, rb_intern("foreach"), 3, self, rbSep, rbBlock); } That doesn't work, however. I've tried various combinations of arrays, and rb_funcall2, but I haven't had any luck. I've seen some mention of rb_iterate, but I wasn't sure how to apply it here. Any ideas? Regards, Dan