From: Robert Klemme Date: 2004-09-06T02:00:12+09:00 Subject: Re: Hashes and ordering "Hal Fulton" schrieb im Newsbeitrag news:413A2C57.1090101@hypermetrics.com... > Oops... thought you sent that one just to me. Got the cc first. > > I'll reply to the list also: > > > Ara.T.Howard@noaa.gov wrote: > > > require 'arrayfields' > > Hi, Ara... yes, I know about arrayfields and have played with it. > I like it. > > However, I really like the "=>" notation, and I want something > fairly fundamental to the language. > > > i think the literal syntax is pretty clear: > > It's clear, yes, but it's not convenient (to me). > I really prefer {x=>y} or the new {x:y}. Well, at least you can do def SortedMap(h) # any transformation of a Hash that # does not depend on insertion order # for example h.sort end foo = SortedMap( "foo" => "bar", "two" => 2 ) foo.each {|k,v| print "key=", k, " value=", v, "\n" } def InsertionOrder(*words) words = words.shift if words.size == 1 && Array === words[0] map = [] until words.empty? map << [words.shift, words.shift] end map end bar = InsertionOrder %w{foo bar 1 2} bar.each {|k,v| print "key=", k, " value=", v, "\n" } Those method names might not be the best, but you get the picture. IMHO that covers already some cases. robert