title: How to concatenate a string value in a hash
body: <p>I am opening a file with terms associated to codes. A line in the file appears as follows:</p>
  
  <pre class="lang-none prettyprint-override"><code>Pacific Ocean; D01.330.322
  </code></pre>
  
  <p>I would like them to appear in a hash. Some terms appear more than once, and I want to put its values in one string joined by <code>","</code>. The code I have is:</p>
  
  <pre><code>descriptor_code_hash = Hash.new
  File.open('mtrees2014.bin').each do |file_line|
    file_line = file_line.chomp
    mesh_descriptor, tree_code = file_line.split(/\;/)
    descriptor_code_hash[mesh_descriptor] = tree_code
    if descriptor_code_hash.has_key? mesh_descriptor
      tree_code &lt;&lt; "," &lt;&lt; tree_code 
    else 
      descriptor_code_hash[mesh_descriptor] 
    end
  end 
  </code></pre>
  
  <p>When a term has multiple codes, the same code is concatenated once and the other unique codes for that term are not identified. Also, I don't know how to write the script to get all the codes, for example, some of the terms have six codes.</p>