<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - noah</title>
<link>http://snipplr.com/users/noah/tags/each</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Tue, 14 Feb 2012 20:16:39 GMT</pubDate>
<item>
<title>(Ruby) Detect the first and last iteration of a loop in Ruby</title>
<link>http://snipplr.com/view/12419/detect-the-first-and-last-iteration-of-a-loop-in-ruby/</link>
<description><![CDATA[ <p>It's great that, at the times I really need it, I can ask for Ruby help on `#nyc.rb`:

      how can I detect the first or last iteration of a loop in
                      Ruby or Rails?                       
      what sort of loop? an array loop?
      or something else?
      f == array.first?
      in case of an array you want #each_with_index
      yah each_with_index would do it, thanks much 
      I'm looping through an array printing LIs and I want to apply
                      css classes to the first and last LIs respectively</p> ]]></description>
<pubDate>Fri, 20 Feb 2009 13:44:51 GMT</pubDate>
<guid>http://snipplr.com/view/12419/detect-the-first-and-last-iteration-of-a-loop-in-ruby/</guid>
</item>
</channel>
</rss>
