From: Graham Wideman Date: 2006-08-26T04:25:05+09:00 Subject: Re: Collections of structured-data objects: what approach? 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? 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?) 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". Thanks for your reply, Graham -- --------------------------------------------------- Graham Wideman Microsoft Visio MVP --------------------------------------------------- Book/Tools: Visio 2003 Developer's Survival Pack Resources for programmable diagramming at: http://www.diagramantics.com