Ordered hash hack for < ruby 1.9?

Ben J. wrote:

Is there anything out there that does this? Thanks for your help.
FWIW, JRuby is 1.8.6ish and has insertion-ordered hashes like 1.9.

  • Charlie

On Oct 2, 2008, at 11:05 PM, Ben J. wrote:

Thanks Erik, I agree 100%. I ONLY applied this when testing,

but that invalidates the tests :wink:

where
performance really isn’t an issue. I just needed hashes to iterate
in a
consistent order. What was unique about my situation is that the hash
order didn’t matter to the functional purpose of the method. It
mattered
only when I needed to do assertions in my tests.

Honestly, if order if meaningful you should use an array. I think
any of
the above gems are not the best choice when it comes to performance.

arrayfields gives you both - an array with hash access

a @ http://codeforpeople.com/