From: Aredridel Date: 2004-09-05T08:39:38+09:00 Subject: Re: Hashes and ordering Oooh, I like that! On Sun, 5 Sep 2004 08:15:38 +0900, T. Onoma wrote: > On Saturday 04 September 2004 06:15 pm, Hal Fulton wrote: > > > I won't address this today, but I will save this list. > > I talked this nearly to death about two years ago. It's somewhere in the > ruby-talk archives. But to summarize: > > I came up with the idea of an indexed hash, basically a combined version of an > array and a hash, that could do both's job, plain and simple. But others told > me it would cause lookup conflicts because the hash key could be an integer. > The fix is to have different lookup mechanisms. > > ih = [ :a => 1, :b => 2 ] > > ih[0] #=> 1 > ih[1] #=> 2 > > ih{:a} #=> 1 > ih{:b} #=> 2 > > ih.pair(0) #=> :a, 1 > ih.pair(1) #=> :b, 2 > > etc. > > At one point I even asked what others thought about association (=>) being an > operator/method. You could arbitrarily do it anywhere. > > a = "bomb!" > a => 'hal' # returns an association object > > # also links 'hal' into a > p "#{a} is the #{a.association}" #=> "Hal is the bomb!" > > Obviously this could then be utilized by arrrays. > > [ :a => 1, :b => 2 ] > > An array of two associations. > > Would be fun to play with this some more. > > -T > >