title: last element in Hash.each
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4000713/tell-the-end-of-a-each-loop-in-ruby">Tell the end of a .each loop in ruby</a>  </p>
  </blockquote>
  
  
  
  <p>I have a Hash:</p>
  
  <pre><code> =&gt; {"foo"=&gt;1, "bar"=&gt;2, "abc"=&gt;3} 
  </code></pre>
  
  <p>and a code:</p>
  
  <pre><code>foo.each do |elem|
    # smth
  end
  </code></pre>
  
  <p>How to recognize that an element in cycle is last?
  Something like </p>
  
  <pre><code>if elem == foo.last
    puts 'this is a last element!'
  end
  </code></pre>