<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 3 times ActiveSupport 3</title>
	<atom:link href="http://iain.nl/2010/02/3-times-activesupport-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://iain.nl/2010/02/3-times-activesupport-3/</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 12:35:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: iain.nl &#187; Monkey Patch of the Month: group_by</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-725</link>
		<dc:creator>iain.nl &#187; Monkey Patch of the Month: group_by</dc:creator>
		<pubDate>Fri, 19 Mar 2010 15:10:33 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-725</guid>
		<description>[...] while back, I talked about new additions to ActiveSupport. And now, I have a confession to make: I like monkey patches! At least, as long as they&#8217;re [...]</description>
		<content:encoded><![CDATA[<p>[...] while back, I talked about new additions to ActiveSupport. And now, I have a confession to make: I like monkey patches! At least, as long as they&#8217;re [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iain Hecker</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-711</link>
		<dc:creator>Iain Hecker</dc:creator>
		<pubDate>Sun, 14 Feb 2010 23:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-711</guid>
		<description>You never have to rely on both obj.nil? and obj.blank? as blank? will check for nil? too...

Anyway, there are a lot of plugins and gems still not working on Rails 3. I wouldn&#039;t upgrade your app just yet. If you have plugins, please make sure they work and put a notice on http://railsplugins.org/

I backport some of the useful ActiveSupport features from Rails 3 into existing Rails 2 apps.</description>
		<content:encoded><![CDATA[<p>You never have to rely on both obj.nil? and obj.blank? as blank? will check for nil? too&#8230;</p>
<p>Anyway, there are a lot of plugins and gems still not working on Rails 3. I wouldn&#8217;t upgrade your app just yet. If you have plugins, please make sure they work and put a notice on <a href="http://railsplugins.org/" rel="nofollow">http://railsplugins.org/</a></p>
<p>I backport some of the useful ActiveSupport features from Rails 3 into existing Rails 2 apps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CodeJoust - Iain</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-710</link>
		<dc:creator>CodeJoust - Iain</dc:creator>
		<pubDate>Sun, 14 Feb 2010 18:20:50 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-710</guid>
		<description>Looks good - I know that rails 3.0beta1 is trunk, but any idea on when it will be released as a final release? Is it a good idea to start writing apps in it, or should I wait for the final release?
I really like the changes, and it&#039;ll be nicer to use more ruby to condense the code instead of relying on something else, along with shortcuts like present?, and various helper methods to replace &#039;unless obj.nil? &#124;&#124; obj.blank?&#039;.</description>
		<content:encoded><![CDATA[<p>Looks good &#8211; I know that rails 3.0beta1 is trunk, but any idea on when it will be released as a final release? Is it a good idea to start writing apps in it, or should I wait for the final release?<br />
I really like the changes, and it&#8217;ll be nicer to use more ruby to condense the code instead of relying on something else, along with shortcuts like present?, and various helper methods to replace &#8216;unless obj.nil? || obj.blank?&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zigzag</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-705</link>
		<dc:creator>zigzag</dc:creator>
		<pubDate>Thu, 04 Feb 2010 09:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-705</guid>
		<description>&lt;a href=&quot;#comment-704&quot; rel=&quot;nofollow&quot;&gt;@Iain Hecker &lt;/a&gt; 
Yes, you are right.

I read it again, from the your &quot;post name&quot; example i figured out what the usage it is.
Thanks.</description>
		<content:encoded><![CDATA[<p><a href="#comment-704" rel="nofollow">@Iain Hecker </a><br />
Yes, you are right.</p>
<p>I read it again, from the your &#8220;post name&#8221; example i figured out what the usage it is.<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iain Hecker</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-704</link>
		<dc:creator>Iain Hecker</dc:creator>
		<pubDate>Thu, 04 Feb 2010 08:25:36 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-704</guid>
		<description>&lt;a href=&quot;#comment-702&quot; rel=&quot;nofollow&quot;&gt;@zigzag &lt;/a&gt; you&#039;re wrong, because uniq_by isn&#039;t just about it&#039;s boolean value, but also other values, like string. For example:

&lt;pre&gt;posts.uniq_by { &#124;post&#124; post.name.downcase }&lt;/pre&gt;

This is why the results of the block are used as keys in the temporary hash.

I think the description in my post wasn&#039;t really accurate. It&#039;s not a select in that it&#039;s not important if the block returns true or false. It will even treat false and nil differently:

&lt;pre&gt;
[ true, false, nil, 1, 2, nil, 2, false ].uniq_by { &#124;x&#124; x }
#=&gt; [ true, false, nil, 1, 2 ]
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p><a href="#comment-702" rel="nofollow">@zigzag </a> you&#8217;re wrong, because uniq_by isn&#8217;t just about it&#8217;s boolean value, but also other values, like string. For example:</p>
<pre>posts.uniq_by { |post| post.name.downcase }</pre>
<p>This is why the results of the block are used as keys in the temporary hash.</p>
<p>I think the description in my post wasn&#8217;t really accurate. It&#8217;s not a select in that it&#8217;s not important if the block returns true or false. It will even treat false and nil differently:</p>
<pre>
[ true, false, nil, 1, 2, nil, 2, false ].uniq_by { |x| x }
#=> [ true, false, nil, 1, 2 ]
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caffeine Driven Development &#187; Blog Archive &#187; L33t Links #76</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-703</link>
		<dc:creator>Caffeine Driven Development &#187; Blog Archive &#187; L33t Links #76</dc:creator>
		<pubDate>Thu, 04 Feb 2010 07:18:56 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-703</guid>
		<description>[...] 3 times ActiveSupport 3, &#8220;3 random new methods added to ActiveSupport&#8221; [...]</description>
		<content:encoded><![CDATA[<p>[...] 3 times ActiveSupport 3, &#8220;3 random new methods added to ActiveSupport&#8221; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zigzag</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-702</link>
		<dc:creator>zigzag</dc:creator>
		<pubDate>Thu, 04 Feb 2010 04:01:45 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-702</guid>
		<description>or Maybe this version is more readable:

&lt;code&gt;
def uniq_by
  hash, array = {}, []
  each { &#124;i&#124; hash[i] &#124;&#124;= (array &lt;&lt; i) if yield(i)}
  array
end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>or Maybe this version is more readable:</p>
<p><code><br />
def uniq_by<br />
  hash, array = {}, []<br />
  each { |i| hash[i] ||= (array &lt;&lt; i) if yield(i)}<br />
  array<br />
end<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zigzag</title>
		<link>http://iain.nl/2010/02/3-times-activesupport-3/comment-page-1/#comment-701</link>
		<dc:creator>zigzag</dc:creator>
		<pubDate>Thu, 04 Feb 2010 03:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://iain.nl/?p=613#comment-701</guid>
		<description>[ 1, 2, 3, 4 ].uniq_by(&amp;:odd?) # =&gt; [ 1, 2 ]

Is it right?

I checked the source code, it is written 
&lt;code&gt; 
 def uniq_by
    hash, array = {}, []
    each { &#124;i&#124; hash[yield(i)] &#124;&#124;= (array &lt;&lt; i) }
    array
  end
&lt;/code&gt;
I think it should be:
&lt;code&gt; 
 def uniq_by
    hash, array = {}, []
    each { &#124;i&#124; !yield(i) &#124;&#124; hash[i] &#124;&#124;= (array &lt;&lt; i) }
    array
  end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>[ 1, 2, 3, 4 ].uniq_by(&amp;:odd?) # =&gt; [ 1, 2 ]</p>
<p>Is it right?</p>
<p>I checked the source code, it is written<br />
<code><br />
 def uniq_by<br />
    hash, array = {}, []<br />
    each { |i| hash[yield(i)] ||= (array &lt;&lt; i) }<br />
    array<br />
  end<br />
</code><br />
I think it should be:<br />
<code><br />
 def uniq_by<br />
    hash, array = {}, []<br />
    each { |i| !yield(i) || hash[i] ||= (array &lt;&lt; i) }<br />
    array<br />
  end<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
