title: ruby: how to iterate elements in a hash efficiently
body: <p>I have a very big hash and I want to iterate it. <code>Hash.each</code> seems to be too slow.
  Is there any efficient way to do this?</p>
  
  <p>How about convert this hash to an array?</p>
  
  <hr>
  
  <p>In each loop I'm doing very simple string stuff:</p>
  
  <pre><code>name_hash.each {|name, str|
  
    record += name.to_s + "\|" + str +"\n"
  
  }
  </code></pre>
  
  <p>and the hash uses people's names as the key, some related content as the value:</p>
  
  <pre><code>name_hash = {:"jose garcia" =&gt; "ca:tw#2@1,2@:th#1@3@;ar:tw#1@4@:fi#1@5@;ny:tw#1@6@;"}
  </code></pre>