From: Tom Sawyer Date: 2002-08-27T11:38:01+09:00 Subject: Re: Hybrid hash and array? > You could always use Array#assoc... > > @choices.assoc('1')[1] # 'Spring' > @choices.assoc('3')[1] # 'Fall' > oh once again, the elusive ordered hash. ;-) On Mon, 2002-08-26 at 16:26, Hal E. Fulton wrote: > ----- Original Message ----- > From: "Philip Mak" > To: "ruby-talk ML" > Sent: Monday, August 26, 2002 5:14 PM > Subject: Hybrid hash and array? > > > > When programming radio buttons on a website, I find myself using this > > sort of construct a lot: > > > > @choices = [ > > ['1', 'Spring'], > > ['2', 'Summer'], > > ['3', 'Fall'] > > ] > > > > @table = {} > > @choices.each do |key, value| > > @table[key] = value > > end > > > > The data structure I really want is like a hash, except that it > > maintains its key/value pairs in the order that I defined them. > > > Hal > > > -- ~transami