Confusion with extension modules


I’m trying to write a very simple extension module using the example -

This is my version. The other methods are defined elsewhere. This
compiles and loads into irb.

void Init_dumphead()
dumphead = rb_define_class(“head”, rb_cObject);
rb_define_singleton_method(dumphead, “new”, dh_new, 0);
rb_define_method(dumphead, “initialize”, dhead_init, 0);

The example refers directly to its version of “head”, but when I try to
do this, I get a NameError on head. I’m also confused about what is
being imported into the environment. Is dumphead (from Init_dumphead)
a module? Wouldn’t I have to refer to head using dumphead::head? If
not, how would I make it a module?


I got it! It needs to be Head, not head.