<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: range code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 21 Aug 2008 01:26:39 GMT</pubDate>
    <description>DZone Snippets: range code</description>
    <item>
      <title>Ruby: make ranges always include the last value</title>
      <link>http://snippets.dzone.com/posts/show/3808</link>
      <description>So, in conjunction with other snipped about setting up intervals on Time, this can be added to Range to make sure it always includes the last value, even if the interval doesn't directly land you on the end value&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Range&lt;br /&gt;  def each(options = {}, &amp;block)&lt;br /&gt;    val = self.begin&lt;br /&gt;    while val &lt; self.end&lt;br /&gt;      yield val&lt;br /&gt;      val = val.succ&lt;br /&gt;    end&lt;br /&gt;    yield self.end if self.end == val || options[:always_include_last]&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 12 Apr 2007 17:36:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3808</guid>
      <author>technodolt (Luke Ivers)</author>
    </item>
  </channel>
</rss>
