Doing a splat within a C extension

Hi all,

Say I have an array VALUE. How would I splat that value within a C
extension?

/* test.c */
VALUE ary1 = rb_ary_new();
VALUE ary2 = rb_ary_new();

rb_ary_push(ary2, rb_str_new2("hello"));

rb_ary_push(ary1, ary2); /* Wrong - ary1 is now [["hello"]]
/* end test.c */

I know in this particular case I could use rb_ary_concat(), but I was
just wondering in general how you do this.

Thanks,

Dan

I know in this particular case I could use rb_ary_concat(), but I was
just wondering in general how you do this.

I've not understood but look at splat_value() in eval.c

Guy Decoux

ts wrote:

> I know in this particular case I could use rb_ary_concat(), but I was
> just wondering in general how you do this.

I've not understood but look at splat_value() in eval.c

Guy Decoux

I saw that, but it didn't seem to be doing anything special. Also, I
can't use it if I want to, say, make a patch on array.c because it
doesn't see it yet.

I suppose I can just iterate of the array via RARRAY. I thought there
might be an easier way.

Regards,

Dan

I saw that, but it didn't seem to be doing anything special.

it call rb_Array() with an exception for Qnil

rb_ary_concat(rb_Array()) do a splat

Guy Decoux