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

Purpose of rb_assoc_new()

23 views
Skip to first unread message

Ian Macdonald

unread,
Feb 25, 2005, 3:12:11 PM2/25/05
to
Hello,

I recently took over the maintenance of the Ruby/LDAP library and am
stuck on interpreting the following line:

tmp = rb_assoc_new (op, rb_ary_new ());

I can't find an explanation of rb_assoc_new() anywhere. It's used all
over the Ruby source code and yet I still can't figure what's going on.

I know that rb_ary_new() makes a new array, which is presumably being
associated with tmp, but what does op have to do with it?

array.c has the definition:

VALUE
rb_assoc_new(car, cdr)
VALUE car, cdr;
{
VALUE ary;

ary = rb_ary_new2(2);
RARRAY(ary)->ptr[0] = car;
RARRAY(ary)->ptr[1] = cdr;
RARRAY(ary)->len = 2;

return ary;
}

Is this just a convenient way to instantiate a two element array?

Ian
--
Ian Macdonald | He knew the tavernes well in every toun.
System Administrator | -- Geoffrey Chaucer
i...@caliban.org |
http://www.caliban.org |
|


Marcelo Paniagua

unread,
Feb 25, 2005, 3:15:49 PM2/25/05
to
Do anyone know about a library capable of generating a printable report?

> --
> Este correo esta libre de virus!
>


--
Este correo esta libre de virus!

Austin Ziegler

unread,
Feb 25, 2005, 3:22:21 PM2/25/05
to
On Sat, 26 Feb 2005 05:15:49 +0900, Marcelo Paniagua
<pani...@pcmxl.com.mx> wrote:
> Do anyone know about a library capable of generating a printable report?

Why, yes.

PDF::Writer.

But wait -- there's a major release coming out in the next couple of
weeks; I don't think that I'm going to make my original target date of
1 March, but it shouldn't be too much longer after that.

-austin
--
Austin Ziegler * halos...@gmail.com
* Alternate: aus...@halostatue.ca


Charles Mills

unread,
Feb 25, 2005, 5:01:52 PM2/25/05
to
Ian Macdonald wrote:
> Hello,
>
> I recently took over the maintenance of the Ruby/LDAP library and am
> stuck on interpreting the following line:
>
> tmp = rb_assoc_new (op, rb_ary_new ());
>
> I can't find an explanation of rb_assoc_new() anywhere. It's used all
> over the Ruby source code and yet I still can't figure what's going
on.
>
> I know that rb_ary_new() makes a new array, which is presumably being
> associated with tmp, but what does op have to do with it?
>
(...)

> Is this just a convenient way to instantiate a two element array?
>
This seems to be the most common use. Perhaps in the future it may
have a different meaning (if there was some kind of Assoc Class..??
like described here:
http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/46128 ).

-Charlie

Marcelo Paniagua

unread,
Feb 25, 2005, 7:56:53 PM2/25/05
to
Thanks! Checked the units and they seems great.. Will test them on
weekend..

See you
Marcelo


----- Original Message -----
From: "Austin Ziegler" <halos...@gmail.com>
To: "ruby-talk ML" <ruby...@ruby-lang.org>

Yukihiro Matsumoto

unread,
Feb 25, 2005, 9:42:37 PM2/25/05
to
Hi,

In message "Re: Purpose of rb_assoc_new()"


on Sat, 26 Feb 2005 05:12:11 +0900, Ian Macdonald <i...@caliban.org> writes:

|Is this just a convenient way to instantiate a two element array?

Yes.

matz.


0 new messages