2009/2/13 David A. Black <dblack / rubypal.com>

> 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.