From: matz@... (Yukihiro Matsumoto) Date: 2003-03-25T12:48:17+09:00 Subject: Re: Writing a new method in C for a subclass Hi, In message "Re: Writing a new method in C for a subclass" on 03/03/25, David King Landrith writes: |I am wondering if there is anything special that I must do to create a |method that instantiates a new MyArray object in c. All of the |examples of "new" methods (meaning a methods that are declared using |the form rb_define_singleton_method(myClass, "new", myClass_new, argc) |simply extend rb_cObj. If you're using 1.8.0, you just need to call ary = rb_obj_alloc(YourArraySubclass); to get new instance of your class. But since allocated instance is an empty array, you need to call rb_ary_store() to store object to allocate internal buffer. Making a subclass of built-in classes is more difficult than making subclass of Object. You may need to dig into the interpreter source code. matz.