From: Roger Pack Date: 2008-09-05T02:02:32+09:00 Subject: Re: Hash optimization question > Why do that? Your identifiers is constant anyway - as far as I can > see. Why not just do > > identifiers = {/abc/ => 'an abc line', /def/ => 'a def line'}.to_a Yeah--works like a charm. This makes me wish that there were a data structure that has object-based O(1) lookup/insertion/deletion, and O(n) .each calls. Apparently Hash doesn't :) My theory is that some people use hashes just for the convenience of object-based lookup [ex: scope[:include] in rails] and not for the real strength of hashes, which, as you mentioned, is "efficient lookup/insertion/deletion" Thanks! -=R -- Posted via http://www.ruby-forum.com/.