title: Effective way to create on-the-fly arrays/hashes with ruby?
body: <p>What I want to do is something like this:</p>
  
  <pre><code>arr = %w(good bad great dull)
  "Today was a #{arr.sample} day"
  </code></pre>
  
  <p>Say I wanted to then loop this 100 times and count each sampled element, and collect the counters in a separate hash or array, how would I do that? And would this be better approached with a hash or an array?</p>
  
  <p>Something like:</p>
  
  <pre><code>counter = []
  arr.each { |el| counter &lt;&lt; [el =&gt; 0] }
  
  100.times do 
    el = arr.sample
    # lost here..
  end
  </code></pre>
  
  <p>Output I want (array or hash):</p>
  
  <pre><code>["good" =&gt; 20, "bad" =&gt; 20, "great" =&gt; 40, "dull" =&gt; 20]
  </code></pre>
  
  <p>I also figure there is a more elegant solution to my first way of thinking.</p>