Is there a way to iterate through a hash with index values?
<p>I am writing a program to “correct” a current hash that I have. I have a hash who’s key-value pairs are "off" by just one. This is the incorrect hash: </p>

<pre><code>wrong_hash = {:a =&gt; "banana", :b =&gt; "cabbage", :c =&gt; "dental_floss", :d =&gt; "eel_sushi”}
</code></pre>

<p>:c needs to be paired to “cabbage”,
:b needs to be paired to “banana”
etc</p>

<p>This is what I have so far. I am having trouble creating the variable <code>new_item</code></p>

<pre><code>def hash_correct(hash)
 correct_hash = {}

 hash.each do |key, item|
 new_item = 
  correct_hash &lt;&lt; hash[key] = new_item
end

return correct_hash

end
</code></pre>

<p>NOTE: My interest is not so much to just get the correct answer, and I understand there are other ways to go about it (sort, while loop, etc) I just want to know if there is a way to include an index variable in my block. Something like |key, item, index| </p>

<p>I am a newbie so any help is much appreciated!!</p>