[Ruby] splatting arguments in a C extension

John Barnette jbarnette at gmail.com
Sat Feb 2 00:40:51 PST 2008


On Feb 1, 2008 10:53 PM, Aaron Patterson <aaron at tenderlovemaking.com> wrote:
> On Fri, Feb 01, 2008 at 11:08:04PM -0800, John Barnette wrote:
> > On Feb 1, 2008 9:14 PM, Aaron Patterson <aaron at tenderlovemaking.com> wrote:
> > > I'm writing a C extension, and I've got an array that I need to pass to
> > > a function.  I need to splat the array that goes to the function though.
> > > Anyone know how to do this?  I couldn't find much help in the docs.....
> >
> > If you pass -2 as argc in rb_define_method, the function will behave
> > as splatted: it'll get self and *args as arguments.
>
> Hmmmm...  I shouldn't have "thanks brooo"'d so quickly.  The function is
> defined in ruby, and I'm calling it from C.  I need to get the
> rb_funcall to splat my args (heh).

In that case, you probably want rb_funcall2. :)


~ j.


More information about the Ruby mailing list