From: Kristof Bastiaensen Date: 2004-09-04T17:00:21+09:00 Subject: Re: Hashes and ordering On Sat, 04 Sep 2004 12:39:31 +0900, Hal Fulton wrote: > Markus wrote: >> Where are you going with this? There seem to be three unrelated things >> here: > > Well, I have been thinking along the lines of: What if we had a built-in > ordered indexable collection in Ruby? > What about an association list (Array)? [["one", 1], ["two", 2], ["three", 3]].assoc("one") => ["one", 1] You could wrap it in a class to have it behave more like a Hash. >> To see why this seems odd, let me recast your question in terms of >> arrays: >> >> > > [snip] > > Clever analogy, but you're presupposing an unordered arbitrarily indexable > collection. A hash, like our Hash, is inherently unordered, but I am > imagining a similar ordered data structure. > > It's more like: > > x = [1,2] > y = [2,1] > x == y # false - we *do* depend on this being false > > I'm envisioning a data structure that has an order, but is otherwise (in > behavior, not implementation) like our current Hash. > > I don't want to go into detail about what I'm thinking at the moment. > > But I can see where my post was unclear or vague and would raise very > valid questions in your mind. > > > Hal Regards, KB