Purpose of rb_assoc_new()

I

Ian Macdonald

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
(e-mail address removed) |
http://www.caliban.org |
|
 
M

Marcelo Paniagua

Do anyone know about a library capable of generating a printable report?


----- Original Message -----
From: "Ian Macdonald" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Friday, February 25, 2005 12:12 PM
Subject: Purpose of rb_assoc_new()

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
(e-mail address removed) |
http://www.caliban.org |
|
 
A

Austin Ziegler

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
 
C

Charles Mills

Ian said:
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
 
M

Marcelo Paniagua

Thanks! Checked the units and they seems great.. Will test them on
weekend..

See you
Marcelo
----- Original Message -----
From: "Austin Ziegler" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Friday, February 25, 2005 12:22 PM
Subject: Re: Reports on Ruby
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Purpose of rb_assoc_new()"

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

Yes.

matz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top