title: Why doesn't iterating over each index of a string not function correctly?
body: <p>I'm trying to perform an operation on each character of a string which is followed by another character, i.e. one that is not the last character. My code is:</p>
  
  <pre><code>[0..(str.length - 2)].each do |index|
      // do something with index
  end
  </code></pre>
  
  <p>The code errors out. <code>[0..(str.length - 2)]</code> returns a range object rather than an actual range which can be iterated over. Putting a <code>return index</code> in the body of the above causes a single iteration, with an output of something like <code>[0..7]</code>. Why isn't this iterating over each number?</p>