From: Leo Laursen <1858323m001@...1.stofanet.dk> Date: 2001-12-12T00:58:26+09:00 Subject: [ruby-talk:28235] Re: Hash.keys Q Den 12-12 2001 kl. 12:26:31 +0900, skrev ts: >> Now options.keys returns ["Password", "Host", "Port", "Name"] >> I would expect ["Host", "Port", "Name", "Password"] >> is there an explanation for this ? > Yes, the order of the keys in an Hash depend of the hash function. For > example in your case, the order is given by > pigeon% cat b.rb > #!/usr/bin/ruby > ["Password", "Host", "Port", "Name"].each do |key| > puts "#{key} -- #{key.hash % 10}" > end > pigeon% > pigeon% b.rb > Password -- 2 > Host -- 7 > Port -- 8 > Name -- 9 > pigeon% > 10 is the default size value when ruby build an Hash This is excellent! To be honest i don't understand it fully, but at least I know what to look for in my studies. Thanks. Leo -- Al didn't smile for forty years. You've got to admire a man like that. -- from "Mary Hartman, Mary Hartman"