title: In Ruby, how do I return all the index value of elements in an array that have the same string values in them?
body: <p>How do I return all the index value of elements in an array that have the same string values in them?</p>
  
  <p>For example: </p>
  
  <pre><code>myarray=[tree, bean, bean, bunny, frog, bean, soup]   
  </code></pre>
  
  <p>If I searched for "bean" using something <code>myarray.index(bean)</code> it would return 1. If I did the same search using <code>myarray.rindex(bean)</code> it would return 5.</p>
  
  <p>I need the method to <code>myarray.{does this method exist?}(bean)</code> that would return <code>[1, 2, 5]</code>.</p>
  
  <p>Any suggestions?</p>