D
Daniel Berger
Hi all,
This appears to be perfectly legal Ruby code:
module Foo
class Bar
end
class Bar::Baz
end
end
p Foo::Bar.new # ok
p Foo::Bar::Baz.new # ok
However, an equivalent C extension has problems:
void Init_foo(){
VALUE mFoo = rb_define_module("Foo");
VALUE cBar = rb_define_class_under(mFoo, "Bar", rb_cObject);
VALUE cBarBaz = rb_define_class_under(mFoo, "Bar::Baz", rb_cObject);
}
p Foo::Bar.new # ok
p Foo::Bar::Baz.new # uninitialized constant Foo::Bar::Baz (NameError)
Why doesn't that work?
The only way I could get it to work was to declare "Baz" under "Bar". But is
that really the same thing?
Regards,
Dan
PS - I may have asked this before, but I'm old, my mind is going and Google is
failing me.
This appears to be perfectly legal Ruby code:
module Foo
class Bar
end
class Bar::Baz
end
end
p Foo::Bar.new # ok
p Foo::Bar::Baz.new # ok
However, an equivalent C extension has problems:
void Init_foo(){
VALUE mFoo = rb_define_module("Foo");
VALUE cBar = rb_define_class_under(mFoo, "Bar", rb_cObject);
VALUE cBarBaz = rb_define_class_under(mFoo, "Bar::Baz", rb_cObject);
}
p Foo::Bar.new # ok
p Foo::Bar::Baz.new # uninitialized constant Foo::Bar::Baz (NameError)
Why doesn't that work?
The only way I could get it to work was to declare "Baz" under "Bar". But is
that really the same thing?
Regards,
Dan
PS - I may have asked this before, but I'm old, my mind is going and Google is
failing me.