On 23.02.2009 21:00, Daniel Schoch wrote:
> I just started with ruby and I understand from reading the documentation
> that pointers don't exist. I'm in the process of writing a netlister.
> Such a software is usually built using several linked lists. More
> precisely, each element of one list contains a pointer to an element of
> some other list.
> So I was wondering how this can be achieved.

Try this in IRB for example:

ListElem = Struct.new :prev, :next, :data
l1 = ListElem.new
li.data = "foo"
l2 = ListElem.new
l2.prev = l1
l1.next = l2
l2.data = "bar"
p l1

> And while I'm at it I also have the following questions which I didn't
> find an answer for in the litarature.
> 1.
> @names.each do |name|
> I understand what the line is doing, but why is |name| in the pipe?
> What's the definiton of |xx| ?

It's a block parameter - similar bot not identical to a method parameter 
(a block can be viewed as an anonymous function).

> 2.
> I came across this in an example piece of ruby code:
> options[:verbose] = x
> I thought this is a hash with key verbose. But Im not sure now, why is
> this :verbose and not options["verbose"]?

Because the author chose to use Symbol over String for keys.  This is 
often done when the number of keys is known and limited.

The introductory material out there (hint, hint :-)) can probably 
explain this a lot better and more exhaustively.

Cheers

	robert