Adam Shelly
4/29/2008 5:38:00 AM
On Mon, Apr 28, 2008 at 10:15 PM, Niklas C. <cathor.niklas@gmail.com> wrote:
> Whow, that really gave me a hint!
> Doing
> ldist 'foo','bar'
> now prints:
>
> main
> 'foo'
>
> So for some reason main is given as the first argument. Does ruby always
> do that? doesn't make much sense to me...
The first argument is always 'self' - the object that the method is
being called on. Your function definition should always have 1 more
parameter than rb_define_method specifies.
>
> Anyway, I solved the problem by adding another (first) parameter to
> rb_ldist, but still specifying 2 parameters down in the rb_define_method
> call. Seems like a dirty hack but it's working, thank's a lot ;)
>
So it's not really a dirty hack - just rename your dummy to 'self' and
you are doing the right thing.
-Adam