title: Return iterating object and index while iterating
body: <pre><code>array = [1,2,3,{:name =&gt; "Peter"}, "hello"]
  array.each do |element| # it can be "inject", "map" or other iterators
    # How to return object "array" and position of "element"
    # also next and priviouse "element"
  end
  </code></pre>
  
  <p>of course I can return index by <code>array.index[element]</code> but I am searching for more natural solution. Like <code>proxy_owner</code> in Rails associations</p>
  
  <p><strong>Ruby 1.8.7</strong></p>
  
  <p>What I want to output? I want to return object wich I iterating (array in my case), also number of iteration (index in case of each_with_index)next and priviouse element of iteration.</p>
  
  <p>As input I have got an Array and iterator (each, map, inject etc)</p>