[Ruby] splatting arguments in a C extension

Aaron Patterson aaron at tenderlovemaking.com
Fri Feb 1 22:53:44 PST 2008


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).

-- 
Aaron Patterson
http://tenderlovemaking.com/


More information about the Ruby mailing list