Graham Wideman wrote:
> Robert:
> 
> Question and then a comment:
> 
> Question: What does the keyword "self" do when sitting on a line by itself, 
> as in several of your methods?

Simen answered that one.  As an additional note, traditionally #each 
returns self.  Also, by doing this you can chain methods.

> Comment:
> 
>> For the sake of discussion I present a different approach.  As long as
>> you don't need 4 (lookup by key) an Array is perfect.  However, with the
>> lookup IMHO a new data structure is preferred because then consistency
>> can be handled internally.  I'll attach a half grown quick hack to
>> demonstrate what I mean.
> 
> If I'm reading you correctly, you are saying a bit more than this:
> 
> 1. For lookup (or for that matter if one want to implement a 
> SortedCollection), then it's desirable to have an index for the array on the 
> key field(s), which can be a ruby hash. (Ie: one *could* use Enumerable#find 
> or find_all, but on larger collections that's slow?)

find is O(n) which can seriously hurt your applications performance if 
the Array grows beyond a certain limit.  Hash lookup on the other hand 
is O(1).

> 2. But if you are going to implement an index using a helper hash, then you 
> want a way to keep the hash up-to-date as items are inserted or deleted from 
> the array.
> 
> 3. So you advocate a class to wrap these together so that "consistency can 
> be handled internally".

Right.  You got it.  That's what OO is about.

Kind regards

	robert