Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple extension question

0 views
Skip to first unread message

Mark Probert

unread,
Mar 10, 2005, 3:30:29 PM3/10/05
to

Hi ..

What is the easy way of clearing an array in an extension?

ie Given

VALUE t_init(VALUE self)
{
VALUE foo;

foo = rb_ary_new();
rb_iv_set(self, "@foo", foo);
}

How do I do the equivalent of "foo.clear" ?

Thanks,

--
-mark. (probertm at acm dot org)


Berger, Daniel

unread,
Mar 10, 2005, 3:34:01 PM3/10/05
to
> -----Original Message-----
> From: Mark Probert [mailto:prob...@acm.org]
> Sent: Thursday, March 10, 2005 1:30 PM
> To: ruby-talk ML
> Subject: Simple extension question
>
>
>
> Hi ..
>
> What is the easy way of clearing an array in an extension?
>
> ie Given
>
> VALUE t_init(VALUE self)
> {
> VALUE foo;
>
> foo = rb_ary_new();
> rb_iv_set(self, "@foo", foo);
> }
>
> How do I do the equivalent of "foo.clear" ?

rb_ary_clear(foo);

Tricky, eh? :-P

For a complete list of methods, take a look at intern.h.

Regards,

Dan

Mark Probert

unread,
Mar 10, 2005, 4:53:08 PM3/10/05
to
Hi ..

On Thursday 10 March 2005 12:34, Berger, Daniel wrote:
>
> rb_ary_clear(foo);
> Tricky, eh? :-P
>
Thanks, Dan. I knew it was something trivial. I haven't done any extension
coding for some time and forgot about 'intern.h'.

Regards,

0 new messages