<?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: Enumerable#every</title>
	<atom:link href="http://mynyml.com/ruby/enumerable_every/feed" rel="self" type="application/rss+xml" />
	<link>http://mynyml.com/ruby/enumerable_every</link>
	<description>%w( yin yang minimalism ) #=&#62; Simplicity</description>
	<pubDate>Wed, 10 Mar 2010 22:06:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nicolas Blanco</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-15</link>
		<dc:creator>Nicolas Blanco</dc:creator>
		<pubDate>Tue, 14 Apr 2009 13:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-15</guid>
		<description>I really like this.
Should be in Rails core for sure!

Nicolas.</description>
		<content:encoded><![CDATA[<p>I really like this.<br />
Should be in Rails core for sure!</p>
<p>Nicolas.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: slothbear</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-14</link>
		<dc:creator>slothbear</dc:creator>
		<pubDate>Tue, 07 Apr 2009 03:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-14</guid>
		<description>Very very nice.  Makes it look like .. no ... *makes* it real Ruby.</description>
		<content:encoded><![CDATA[<p>Very very nice.  Makes it look like .. no &#8230; *makes* it real Ruby.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mynyml</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-13</link>
		<dc:creator>mynyml</dc:creator>
		<pubDate>Fri, 03 Apr 2009 15:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-13</guid>
		<description>There are &lt;a href="http://github.com/mynyml/every/blob/fc84a3fbd9e4579d48c11d61473222050621438b/benchmarks.rb" rel="nofollow"&gt;benchmarks&lt;/a&gt; included in the gem that show the same results. There's no doubt that #every is slower than native #map, and it is slower than Symbol#to_proc.

On ruby v1.8.7 (100_000 iterations)
&lt;pre&gt;
                    total        real
#map:            0.170000 (  0.202195)
Symbol#to_proc:  0.150000 (  0.144365)
#every:          0.240000 (  0.251681)
&lt;/pre&gt;

IMO the difference is not significant enough to matter, though. Noone's expected to use it in a low level library (where you'd probably use native methods as much as possible, or even better, RubyInline ;) ). And 100_000 iterations (or 1_000_000 in your benchmark) is a *lot* of iterations; it's unlikely your biggest worry will be #every.</description>
		<content:encoded><![CDATA[<p>There are <a href="http://github.com/mynyml/every/blob/fc84a3fbd9e4579d48c11d61473222050621438b/benchmarks.rb" rel="nofollow">benchmarks</a> included in the gem that show the same results. There&#8217;s no doubt that #every is slower than native #map, and it is slower than Symbol#to_proc.</p>
<p>On ruby v1.8.7 (100_000 iterations)</p>
<pre>
                    total        real
#map:            0.170000 (  0.202195)
Symbol#to_proc:  0.150000 (  0.144365)
#every:          0.240000 (  0.251681)
</pre>
<p>IMO the difference is not significant enough to matter, though. Noone&#8217;s expected to use it in a low level library (where you&#8217;d probably use native methods as much as possible, or even better, RubyInline ;) ). And 100_000 iterations (or 1_000_000 in your benchmark) is a *lot* of iterations; it&#8217;s unlikely your biggest worry will be #every.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Davis</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-12</link>
		<dc:creator>Ryan Davis</dc:creator>
		<pubDate>Fri, 03 Apr 2009 04:21:52 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-12</guid>
		<description># of iterations = 1000000
                          user     system      total        real
null_time             0.260000   0.000000   0.260000 (  0.281800)
map                  17.120000   0.130000  17.250000 ( 19.205743)
to_proc              44.220000   0.430000  44.650000 ( 50.080658)
every                66.930000   0.670000  67.600000 ( 76.222073)</description>
		<content:encoded><![CDATA[<p># of iterations = 1000000<br />
                          user     system      total        real<br />
null_time             0.260000   0.000000   0.260000 (  0.281800)<br />
map                  17.120000   0.130000  17.250000 ( 19.205743)<br />
to_proc              44.220000   0.430000  44.650000 ( 50.080658)<br />
every                66.930000   0.670000  67.600000 ( 76.222073)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coderrr</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-11</link>
		<dc:creator>coderrr</dc:creator>
		<pubDate>Thu, 02 Apr 2009 15:31:26 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-11</guid>
		<description>Hobo has had this for a long time.  They use *

User.all.*.contacts.flatten.*.last_name.*.capitalize

http://github.com/tablatom/hobo/blob/d8b5b90d630e3911fab8655275cc043217bc32d8/hobosupport/lib/hobo_support/enumerable.rb</description>
		<content:encoded><![CDATA[<p>Hobo has had this for a long time.  They use *</p>
<p>User.all.*.contacts.flatten.*.last_name.*.capitalize</p>
<p><a href="http://github.com/tablatom/hobo/blob/d8b5b90d630e3911fab8655275cc043217bc32d8/hobosupport/lib/hobo_support/enumerable.rb" rel="nofollow">http://github.com/tablatom/hobo/blob/d8b5b90d630e3911fab8655275cc043217bc32d8/hobosupport/lib/hobo_support/enumerable.rb</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mynyml</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-9</link>
		<dc:creator>mynyml</dc:creator>
		<pubDate>Thu, 02 Apr 2009 05:47:34 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-9</guid>
		<description>@Shadowfiend Interesting. I didn't know about Methodphetamine. Pretty clever. Makes for an interesting comparison, actually;

(first three examples from: http://jicksta.com/posts/the-methodphitamine)
User.all.map{&#124;x&#124; x.contacts.map{&#124;y&#124; y.last_name.capitalize }}
User.all.map{&#124;x&#124;x.contacts.map(&amp;:last_name).map(&amp;:capitalize)}
User.all.map &amp;its.contacts.map(&amp;its.last_name.capitalize)
User.all.every.contacts.flatten.every.last_name.every.capitalize</description>
		<content:encoded><![CDATA[<p>@Shadowfiend Interesting. I didn&#8217;t know about Methodphetamine. Pretty clever. Makes for an interesting comparison, actually;</p>
<p>(first three examples from: <a href="http://jicksta.com/posts/the-methodphitamine" rel="nofollow">http://jicksta.com/posts/the-methodphitamine</a>)<br />
User.all.map{|x| x.contacts.map{|y| y.last_name.capitalize }}<br />
User.all.map{|x|x.contacts.map(&#038;:last_name).map(&#038;:capitalize)}<br />
User.all.map &#038;its.contacts.map(&#038;its.last_name.capitalize)<br />
User.all.every.contacts.flatten.every.last_name.every.capitalize</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shadowfiend</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-8</link>
		<dc:creator>Shadowfiend</dc:creator>
		<pubDate>Thu, 02 Apr 2009 05:25:43 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-8</guid>
		<description>Very sexy. A variant on Symbol#to_proc that allows parameters and multiple method calls is the Methodphetamine (http://jicksta.com/posts/the-methodphitamine). It still uses the &amp; syntax, but without many of the limitations of the more traditional #to_proc solution.</description>
		<content:encoded><![CDATA[<p>Very sexy. A variant on Symbol#to_proc that allows parameters and multiple method calls is the Methodphetamine (http://jicksta.com/posts/the-methodphitamine). It still uses the &amp; syntax, but without many of the limitations of the more traditional #to_proc solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mynyml</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-7</link>
		<dc:creator>mynyml</dc:creator>
		<pubDate>Wed, 01 Apr 2009 23:28:41 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-7</guid>
		<description>@Luca yes, I'm working on an ActiveSupport patch atm, but it'll probably be another 2-3 days before I submit it.

@hgs I'm tempted to add other methods too, but at the same time I want to keep the gem as simple as possible. Currently you can have the same results with:

    enum = [ "a", "b", "" ]
    enum.every.empty?.all?    #=&gt; false
    enum.every.empty?.any?  #=&gt; true

Though I must admit #every? and #some? are sexier names! I'll definetly keep those in mind. Thanks for the suggestion.

Btw there's an expiremental branch in the repo that adds the idiom for #select and #reject  (@ http://github.com/mynyml/every/tree/expanded)

@Eric glad you liked it!</description>
		<content:encoded><![CDATA[<p>@Luca yes, I&#8217;m working on an ActiveSupport patch atm, but it&#8217;ll probably be another 2-3 days before I submit it.</p>
<p>@hgs I&#8217;m tempted to add other methods too, but at the same time I want to keep the gem as simple as possible. Currently you can have the same results with:</p>
<p>    enum = [ "a", "b", "" ]<br />
    enum.every.empty?.all?    #=> false<br />
    enum.every.empty?.any?  #=> true</p>
<p>Though I must admit #every? and #some? are sexier names! I&#8217;ll definetly keep those in mind. Thanks for the suggestion.</p>
<p>Btw there&#8217;s an expiremental branch in the repo that adds the idiom for #select and #reject  (@ <a href="http://github.com/mynyml/every/tree/expanded" rel="nofollow">http://github.com/mynyml/every/tree/expanded</a>)</p>
<p>@Eric glad you liked it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: citizen428.blog()</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-6</link>
		<dc:creator>citizen428.blog()</dc:creator>
		<pubDate>Wed, 01 Apr 2009 21:37:02 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-6</guid>
		<description>&lt;strong&gt;Enumberable#filter...&lt;/strong&gt;

	As much as I like Ruby, some constructs I just don&#8217;t find too sexy, e.g.:


[1,2,5,8,7,3,1,9,5].select { &#124;x&#124; x &lt; 5 }


	That&#8217;s why I came up with alternate solution which I find reads nicer than the above code:

	

	I kinda got inspire...</description>
		<content:encoded><![CDATA[<p><strong>Enumberable#filter&#8230;</strong></p>
<p>	As much as I like Ruby, some constructs I just don&#8217;t find too sexy, e.g.:</p>
<p>[1,2,5,8,7,3,1,9,5].select { |x| x &#60; 5 }</p>
<p>	That&#8217;s why I came up with alternate solution which I find reads nicer than the above code:</p>
<p>	I kinda got inspire&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Anderson</title>
		<link>http://mynyml.com/ruby/enumerable_every/comment-page-1#comment-5</link>
		<dc:creator>Eric Anderson</dc:creator>
		<pubDate>Wed, 01 Apr 2009 19:01:03 +0000</pubDate>
		<guid isPermaLink="false">http://mynyml.com/?p=15#comment-5</guid>
		<description>That is friggen AWESOME.

On one hand I have always felt that Symbol#to_proc was nicer than using a full block. But on the other hand arr.map(&amp;:strip) always felt like too much line noise to be Ruby. Felt like I was moving back to Perl. The lack of arguments and blocks also was annoying as you gsub example demonstrates.

But your solution is makes it work better AND more elegant. I will be using this on many projects/tasks to come.</description>
		<content:encoded><![CDATA[<p>That is friggen AWESOME.</p>
<p>On one hand I have always felt that Symbol#to_proc was nicer than using a full block. But on the other hand arr.map(&amp;:strip) always felt like too much line noise to be Ruby. Felt like I was moving back to Perl. The lack of arguments and blocks also was annoying as you gsub example demonstrates.</p>
<p>But your solution is makes it work better AND more elegant. I will be using this on many projects/tasks to come.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
