title: Ruby's Unary * Operator
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/918449/what-is-the-operator-doing-to-this-string-in-ruby">What is the * operator doing to this string in Ruby</a>  </p>
  </blockquote>
  
  
  
  <p>I ran across the following code when looking for an easy way to convert an array to a hash (similar to .Net's ToDictionary method on IEnumerable... I wanted to be able to arbitrarily set the key and the value). </p>
  
  <pre><code>a = [ 1, 2, 3, 4, 5, 6 ]
  h = Hash[ *a.collect { |v| [ v, v ] }.flatten ]
  </code></pre>
  
  <p>My question is, what does the asterisk before <code>a.collect</code> do? </p>
  
  <p>By the way, the code comes from <a href="http://justatheory.com/computers/programming/ruby/array_to_hash_one_liner.html" rel="nofollow noreferrer">http://justatheory.com/computers/programming/ruby/array_to_hash_one_liner.html</a></p>