title: Ruby - mapping an array to hashmap
body: <p>I have an array, and a function that returns a value given a value. Ultimately I want to create a hashmap that has the values of the array as key value, and the result of f(key_value)  as the value. Is there a clean, simple way, like similar to each/map of Array, of doing this using block? </p>
  
  <p>So something that is equivalent to</p>
  
  <pre><code>hsh = {}
  [1,2,3,4].each do |x|
    hsh[x] = f(x)
  end
  </code></pre>
  
  <p>but looks more similar to this, in that it's simple and one line? </p>
  
  <pre><code>results = array.map { | x | f(x) }
  </code></pre>