When I write a module function in a C extension, I found that I need to
include “VALUE self” as the first argument, just as I do when I write a
class method in a C extension. Why is this?
Thanks,
John
John [email protected] writes:
When I write a module function in a C extension, I found that I need to
include “VALUE self” as the first argument, just as I do when I write a
class method in a C extension. Why is this?
You might want it so you can call other module functions on the same
object.
rb_funcall2(self, rb_intern(“boo!”), 0, NULL)
Note that there’s always a self in ruby. Everywhere. And since
there’s no global `self’ handle, it makes sense to pass it in to all
the C method implementations. Nice and consistent, at least.