From: James Coglan Date: 2009-02-13T09:16:39+09:00 Subject: Re: Hash order (was: Re: If you are unhappy with the direction of Ruby 1.8.7+, respond) --000e0cd2a0702a44730462c1c5ff Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/2/12 David A. Black > Hi -- > > On Fri, 13 Feb 2009, James Coglan wrote: > > >>> >>> >>> What do you mean with "Hash ordering"? >>> An order for Hash instances? Hash doesn't define a <=> method. >>> Or iteration order of Hash elements? That wasn't defined >>> in 1.8.6 (I don't know if it is in 1.8.7). >>> >> >> >> >> In 1.8.6, iteration order would be the same as the order that the keys >> appear in the source. To work with 1.8.7, you need to create an empty hash >> and add keys one by one rather than putting them all in a hash literal >> (see >> the patch). >> > > Hashes aren't ordered at all in 1.8, as far as I know. I realise that there is no explicit iteration order specified for hashes in 1.8. All I know is that this patch fixed by 1.8.7 bugs: http://github.com/jcoglan/packr/commit/9ece59428bbd1bfd497b45a2ae4de2d163a24849 Basically involves inserting keys in an explicit order rather than using hash literals. This project uses a bunch of custom collection classes but they're basically wrappers for arrays and hashes that merge array and hash functionality into a single class. The constructors would iterate over the hashes provided and insert values, and this insertion order changed in 1.8.7. I would concede that this is something of a grey area as it's neither a bug fix or an explicit feature addition, but the question was asked about 1.8.6 code that broke, and this is an example. I still have a regex-related bug in this project that I've been unable to fix under 1.8.7. In fact, if anyone is able to fix the last remaining test failure I'd be incredibly grateful. --000e0cd2a0702a44730462c1c5ff--