From: matz@... (Yukihiro Matsumoto) Date: 2001-01-10T17:40:01+09:00 Subject: [ruby-talk:9007] Re: Help: Problem with accessing C extension methods Hi, In message "[ruby-talk:9001] Help: Problem with accessing C extension methods" on 01/01/10, Ville Mattila writes: |I.e. |> ruby -r foo.so -e "foo = Foo.new('bar'); foo.foo" |-e:1: undefined method `foo' for Foo:Class (NameError) | |I don't understand this because |>ruby -r foo.so -e "foo = Foo.new('bar'); p foo.instance_methods;" |["foo"] | |seems to tell good things. I have probably understood something wrong? You are returning class Foo from Foo.new here. |VALUE foo_new(VALUE self, VALUE bar) |{ | rb_iv_set(self, "@foo", bar); | return (self); |} Instead, you have to remain `new' un-redefined and define `initialize' as an instance method. |VALUE foo_init(VALUE self, VALUE bar) |{ | rb_iv_set(self, "@foo", bar); | return (self); |} : | rb_define_method(cFoo, "initialize", foo_init, 1); : Hope this helps matz.