From: James Coglan Date: 2009-02-14T00:25:31+09:00 Subject: Re: If you are unhappy with the direction of Ruby 1.8.7+, respond --000e0cd298448d5d640462ce7772 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/2/13 David A. Black > Hi -- > > On Sat, 14 Feb 2009, Rick DeNatale wrote: > > Sometime after that discussion, Matz, who I know has much more than a >> basic >> understanding of hash-tables, decided that, yes, >> defining the iteration order of Ruby hashes to be by insertion order, and >> that this was easily done with minimal impact to performance/space >> requirements by linking buckets in the internal hash table used to >> IMPLEMENT >> Hash, and made this change in Ruby 1.9, which has been backported to Ruby >> 1.8.7. >> > > Hashes aren't ordered in 1.8.7, though. Seconded -- 1.8.7 is precisely where my code that was relying on insertion order *does not work*. Actually let me be more specific. My code was relying on keys being inserted in the order they appear in a hash literal, and on subsequent iteration occuring in the same order. My own code was maintaining key order explicitly using an array of keys ( http://github.com/jcoglan/packr/blob/3.1/lib/packr/collection.rb), but when using a hash literal to initialize an instance, the keys are not inserted in literal appearance order in 1.8.7. So it may be that 1.8.7 does use insertion order for iteration, but does not use literal appearance order when creating a new hash. --000e0cd298448d5d640462ce7772--