I have recently started playing around with Ruby, and now I am starting
to use it for more serious projects.
I am working on a program that works with quite a bit of data that is
originally stored in array format.
I want to be able to loop through my original data and add or remove
elements.
In another language I would create a linked list, loop through the
original array and add what I need to the list.
However, Ruby seems to lump Arrays and Lists into one object.
I do see the Array class has an insert method, however assuming that
the implementation of an Array is actually a contiguous array in memory,
the insert method will create a new copy of an array with the insert
element appended.
That means that if I want to start with an empty list and insert
10,000 elements, 10,000 arrays will be created out of which I would only
care about the final one.
If that is the case how should I (starting with 0 elementS) append and
create a large linked list ?
This is my impression of what is happening and please help me clear up
any misconceptions I may have. I have scoured Google to some sort of
article about the intention of the Ruby Array class with no luck.