From: Kirk Haines Date: 2006-05-27T01:23:13+09:00 Subject: Re: Equivalent of collections in Java On Friday 26 May 2006 7:56 am, Ryan Leavengood wrote: > work with. Do you consider this a flaw Robert? It seems you do. I > would argue adding too many data structures would overly and > needlessly complicate Ruby, at least where those data structures > provide duplicate functionality, but through different means (linked > list versus array list versus stack, etc.) One of the pleasant things, IMHO, with Ruby is that the core data structures are extremely flexible. So, for many things, they just work and details about how they work can be ignored in lieu of simply getting things done. > 2. In most uses of Ruby, drilling down to determine the right data > structure in the beginning of development is a waste of time and is > certainly premature optimization. If you are writing a script to I don't think this is the right way to say it. One needs to think about the data structure, but one needs to think about it in the context of behavior, not implementation. If Array or Hash has the behavior one needs, move on. You data structure due diligence is done for now. Obviously, if the needed behavior isn't present, then it's time to start thinking about the data structure that will deliver the needed behavior. Now, it would be handy if one could just use a well built LikedList class out of the core if one needed it, but the lack of such a thing doesn't strike me as a problem, either, precisely because the lack of a dizzying array of builtin data structures encourages one to think more about behavior than implementation; it encourages what is, IMHO, the right approach for the vast majority of cases. And for those corner cases that really do need a LinkedList class, the cost of not having one in the core still isn't high because a) it's easy to write these things, and b) a lot of them can be found in a 3rd party library like Facets (facets.rubyforge.org). Kirk Haines