title: Ruby - Pick one element from array by possibility
body: <p>I have an array with 3 elements and I want to pick one and add that into another array base on possibility.</p>
  <p>For example, num 1 has 5% chance to be picked, num 2 has 60% chance to be picked and num 3 has 35% chance to be picked.</p>
  <pre class="lang-rb prettyprint-override"><code>arr = [{:num=&gt;1, :diff=&gt;-29}, {:num=&gt;2, :diff=&gt;5}, {:num=&gt;3, :diff=&gt;25}]
  </code></pre>
  <p>I found below methods from stackoverflow, just wondering if this would work? Or there is another way to do it?</p>
  <pre class="lang-rb prettyprint-override"><code>def get_num(arr)
      case rand(100) + 1
      when 1..5
          p arr[0]
      when 6..65
          p arr[1]
      when 66..100
          p arr[2]
      end
  end
  
  get_num(arr)
  
  
  </code></pre>
  <p>Thanks!</p>