title: Ruby method returning hash value as {}
body: <p>The variable <code>value</code> in the <code>initialize</code> method of <code>LocationList</code> is populated in line 014.  These changes are relected by the <code>print</code> statement in line 015, but the <code>return</code> in line 016 thinks the hash is still empty (scroll right to see return value after <code>=&gt;</code>).</p>
  
  <pre><code>def random_point
    x = rand * 2.0 - 1.0
    y = rand * 2.0 - 1.0
    until x**2 + y**2 &lt; 1.0
      x = rand * 2.0 - 1.0
      y = rand * 2.0 - 1.0
    end
    return [x, y]
  end
  
  class LocationList &lt; Hash
    def initialize(node_list)
      value = {}
      node_list.each {|node| value[node] = random_point }
      print value
      return value
    end
  end
  
  z = ["moo", "goo", "gai", "pan"]
  
  LocationList.new(z)
  #=&gt; {"moo"=&gt;[0.17733298257484997, 0.39221824315332987], "goo"=&gt;[-0.907202436634851, 0.3589265999520428], "gai"=&gt;[0.3910479677151635, 0.5624531973759821], "pan"=&gt;[-0.37544369339427974, -0.7603500269538608]}=&gt; {}
  </code></pre>
  
  <p>Doing substantially the same thing in a global function yields the intended return value:</p>
  
  <pre><code>def foo(node_list)
    value = {}
    node_list.each {|node| value[node] = random_point }
    return value
  end
  
  foo(z)
  #=&gt; {"moo"=&gt;[-0.33410735869573926, -0.4087709899603238], "goo"=&gt;[0.6093966465651919, 0.6349767372996336], "gai"=&gt;[0.718925625951371, -0.6726652512124924], "pan"=&gt;[0.08604969147566277, -0.518636160280254]}
  </code></pre>