From: "David A. Black" Date: 2010-08-01T21:26:26+09:00 Subject: Re: what is the correct way to extend native methods? Hi -- On Sun, 1 Aug 2010, Maurizio De Santis wrote: > Brian Candler wrote: >> What ruby are you using? > > I'm using ruby 1.9.2dev (2010-07-11 revision 28613) [x86_64-linux] , > maybe this is the reason... > > David A. Black wrote: >> They are indeed the same method: >> >> rb_define_method(rb_cArray, "[]", rb_ary_aref, -1); >> rb_define_method(rb_cArray, "slice", rb_ary_aref, -1); >> > > uhm... but if they are the same method, why aliasing the one, the other > does not become aliased? do I have to alias both methods?? and, if yes, > how??? :) I've tried, but with no success... It's one underlying method (C function) with two Ruby names. If you redefine one of the Ruby names you break the binding between that name and the underlying method, and if you add an alias then there's a third name. Each binding is separate; they don't automatically change together. David -- David A. Black, Senior Developer, Cyrus Innovation Inc. The Ruby training with Black/Brown/McAnally Compleat Philadelphia, PA, October 1-2, 2010 Rubyist http://www.compleatrubyist.com