title: How to find all indices of a given element in an array?
body: <p>This code is supposed to add the indices of the word <code>'hello'</code> to the <code>indices</code> array, but it's not adding them to the array:</p>
  
  <pre><code>words = %w(hello how are you then okay then hello how)
  
  def global(arg1, arg2)
    indices = []
    arg1.each do |x, y|
      indices &lt;&lt; y if arg2 == x
    end
    indices
  end
  
  global(words,'hello')
  #=&gt; [nil, nil]
  </code></pre>
  
  <p>What's wrong with my code?</p>