title: Ruby 2.2.1 - string.each_char is not giving unique indices for reoccurring letters - how do I do that?
body: <p>I'm confused by the behavior of each_char, I'm trying to iterate through a string and get the unique, specific index for each character in that string. Ruby seems to not iterate over <em>every</em> discrete character, but rather only one copy of any given character that populates the string.</p>
  
  <pre><code>def test(string)
    string.each_char do |char|
      puts string.index(char)
    end
  end
  
  test("hello")
  test("aaaaa")
  </code></pre>
  
  <p>Produces the result:</p>
  
  <pre><code>2.2.1 :007 &gt;   test("hello")
  0
  1
  2
  2
  4
  
  2.2.1 :008 &gt; test("aaaaa")
  0
  0
  0
  0
  0
  </code></pre>
  
  <p>This seems counter intuitive to the general form of #each in other contexts. I expect the indices for "aaaaa" to be 0, 1, 2, 3, 4 - how can I achieve this behavior?</p>
  
  <p>I looked at the official documentation for String and it doesn't seem to include a method that behaves this way.</p>