<?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: Groovy Makes Iteration Easy</title>
	<atom:link href="http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/feed/" rel="self" type="application/rss+xml" />
	<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/</link>
	<description>Groovy, Grails and OS X tips and tricks</description>
	<lastBuildDate>Sat, 31 Jul 2010 11:43:17 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Josh</title>
		<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/comment-page-1/#comment-842</link>
		<dc:creator>Josh</dc:creator>
		<pubDate>Fri, 05 Dec 2008 00:42:41 +0000</pubDate>
		<guid isPermaLink="false">http://naleid.com/blog/?p=38#comment-842</guid>
		<description>Thanks for posting this, Ted - it&#039;s sometimes difficult to find documentation for iteration in Groovy.  This is great!</description>
		<content:encoded><![CDATA[<p>Thanks for posting this, Ted &#8211; it&#8217;s sometimes difficult to find documentation for iteration in Groovy.  This is great!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tednaleid</title>
		<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/comment-page-1/#comment-841</link>
		<dc:creator>tednaleid</dc:creator>
		<pubDate>Thu, 04 Dec 2008 06:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://naleid.com/blog/?p=38#comment-841</guid>
		<description>Thanks for the feedback guys, I&#039;m glad you found it useful!

@Hamlet: I figured this out in sort of a similar way myself.  One day I was messing around with the metaclass and had it list all of the metaMethods on a custom class that I had.

&lt;pre lang=&quot;groovy&quot;&gt;
class Foo {}

println new Foo().metaClass.metaMethods*.name.unique().sort()

/* prints 

[&quot;addShutdownHook&quot;, &quot;any&quot;, &quot;asType&quot;, &quot;collect&quot;, &quot;dump&quot;, 
&quot;each&quot;, &quot;eachWithIndex&quot;, &quot;every&quot;, &quot;find&quot;, &quot;findAll&quot;, 
&quot;findIndexOf&quot;, &quot;findIndexValues&quot;, &quot;findLastIndexOf&quot;, &quot;getAt&quot;,
&quot;getMetaClass&quot;, &quot;getMetaPropertyValues&quot;, &quot;getProperties&quot;,
&quot;grep&quot;, &quot;identity&quot;, &quot;inject&quot;, &quot;inspect&quot;, &quot;invokeMethod&quot;, &quot;is&quot;, 
&quot;isCase&quot;, &quot;iterator&quot;, &quot;print&quot;, &quot;printf&quot;, &quot;println&quot;, &quot;putAt&quot;, 
&quot;sleep&quot;, &quot;sprintf&quot;, &quot;use&quot;, &quot;with&quot;]
*/
&lt;/pre&gt;

I saw that all of the iteration methods were already on there.  After an initial &quot;WTF?&quot; and some digging into the groovy source, I figured out what was going on.

I eventually found &lt;a href=&quot;http://groovy.codehaus.org/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html&quot; rel=&quot;nofollow&quot;&gt;DefaultGroovyMethods&lt;/a&gt; which is a goldmine of groovy treasures.  It&#039;s also by far the largest class in the groovy source tree (~10,300 lines of code!).  Almost all of the whizzy stuff that you get without doing an &lt;code&gt;import&lt;/code&gt; originates in that file.</description>
		<content:encoded><![CDATA[<p>Thanks for the feedback guys, I&#8217;m glad you found it useful!</p>
<p>@Hamlet: I figured this out in sort of a similar way myself.  One day I was messing around with the metaclass and had it list all of the metaMethods on a custom class that I had.</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Foo <span style="color: #669966;">&#123;</span><span style="color: #669966;">&#125;</span>
&nbsp;
<span style="color: #663366;">println</span> <span style="color: #000000; font-weight: bold;">new</span> Foo<span style="color: #669966;">&#40;</span><span style="color: #669966;">&#41;</span>.<span style="color: #006600;">metaClass</span>.<span style="color: #006600;">metaMethods</span><span style="color: #669966;">*</span>.<span style="color: #006600;">name</span>.<span style="color: #006600;">unique</span><span style="color: #669966;">&#40;</span><span style="color: #669966;">&#41;</span>.<span style="color: #663399;">sort</span><span style="color: #669966;">&#40;</span><span style="color: #669966;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* prints 
&nbsp;
[&quot;addShutdownHook&quot;, &quot;any&quot;, &quot;asType&quot;, &quot;collect&quot;, &quot;dump&quot;, 
&quot;each&quot;, &quot;eachWithIndex&quot;, &quot;every&quot;, &quot;find&quot;, &quot;findAll&quot;, 
&quot;findIndexOf&quot;, &quot;findIndexValues&quot;, &quot;findLastIndexOf&quot;, &quot;getAt&quot;,
&quot;getMetaClass&quot;, &quot;getMetaPropertyValues&quot;, &quot;getProperties&quot;,
&quot;grep&quot;, &quot;identity&quot;, &quot;inject&quot;, &quot;inspect&quot;, &quot;invokeMethod&quot;, &quot;is&quot;, 
&quot;isCase&quot;, &quot;iterator&quot;, &quot;print&quot;, &quot;printf&quot;, &quot;println&quot;, &quot;putAt&quot;, 
&quot;sleep&quot;, &quot;sprintf&quot;, &quot;use&quot;, &quot;with&quot;]
*/</span></pre></div></div>

<p>I saw that all of the iteration methods were already on there.  After an initial &#8220;WTF?&#8221; and some digging into the groovy source, I figured out what was going on.</p>
<p>I eventually found <a href="http://groovy.codehaus.org/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/groovy.codehaus.org/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html?referer=');">DefaultGroovyMethods</a> which is a goldmine of groovy treasures.  It&#8217;s also by far the largest class in the groovy source tree (~10,300 lines of code!).  Almost all of the whizzy stuff that you get without doing an <code>import</code> originates in that file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/comment-page-1/#comment-840</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Wed, 03 Dec 2008 07:30:58 +0000</pubDate>
		<guid isPermaLink="false">http://naleid.com/blog/?p=38#comment-840</guid>
		<description>Heh.  I spent several hours yesterday trying to do this.  I was reading GinA and trying out all kinds of code until I came up with a solution that looks almost exactly like yours (except that I believed I had to make it a MethodClosure data.&amp;iterator()).  If I had only checked GroovyBlogs, I would have had the solution right away. :)</description>
		<content:encoded><![CDATA[<p>Heh.  I spent several hours yesterday trying to do this.  I was reading GinA and trying out all kinds of code until I came up with a solution that looks almost exactly like yours (except that I believed I had to make it a MethodClosure data.&amp;iterator()).  If I had only checked GroovyBlogs, I would have had the solution right away. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: เกรลส์ หกสิบหก » ลูกเล่นของการใช้ iterator</title>
		<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/comment-page-1/#comment-838</link>
		<dc:creator>เกรลส์ หกสิบหก » ลูกเล่นของการใช้ iterator</dc:creator>
		<pubDate>Tue, 02 Dec 2008 23:34:10 +0000</pubDate>
		<guid isPermaLink="false">http://naleid.com/blog/?p=38#comment-838</guid>
		<description>[...] อ่านตัวเต็มได้จากที่นี่ครับ [...]</description>
		<content:encoded><![CDATA[<p>[...] อ่านตัวเต็มได้จากที่นี่ครับ [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/comment-page-1/#comment-837</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Tue, 02 Dec 2008 18:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://naleid.com/blog/?p=38#comment-837</guid>
		<description>Cool stuff! I love Groovy! Thanks :)</description>
		<content:encoded><![CDATA[<p>Cool stuff! I love Groovy! Thanks :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hamlet D'Arcy</title>
		<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/comment-page-1/#comment-832</link>
		<dc:creator>Hamlet D'Arcy</dc:creator>
		<pubDate>Tue, 02 Dec 2008 14:17:45 +0000</pubDate>
		<guid isPermaLink="false">http://naleid.com/blog/?p=38#comment-832</guid>
		<description>It might be worth pointing out that all those iteration methods are defined on Object, not List or Map. All objects in Groovy respond to any(), each(), and every(). See: http://groovy.codehaus.org/groovy-jdk/java/lang/Object.html

After learning this, my code started to look very, very loopy because you can define algorithms that work across data structures treating everything as a List... if an algorithm encounters a non-list then the each() method never iterates without throwing an exception. Nice stuff.</description>
		<content:encoded><![CDATA[<p>It might be worth pointing out that all those iteration methods are defined on Object, not List or Map. All objects in Groovy respond to any(), each(), and every(). See: <a href="http://groovy.codehaus.org/groovy-jdk/java/lang/Object.html" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/groovy.codehaus.org/groovy-jdk/java/lang/Object.html?referer=');">http://groovy.codehaus.org/groovy-jdk/java/lang/Object.html</a></p>
<p>After learning this, my code started to look very, very loopy because you can define algorithms that work across data structures treating everything as a List&#8230; if an algorithm encounters a non-list then the each() method never iterates without throwing an exception. Nice stuff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Taylor</title>
		<link>http://naleid.com/blog/2008/12/01/groovy-makes-iteration-easy/comment-page-1/#comment-831</link>
		<dc:creator>Matthew Taylor</dc:creator>
		<pubDate>Tue, 02 Dec 2008 13:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://naleid.com/blog/?p=38#comment-831</guid>
		<description>Ted, great Groovy stuff!  You gotta love a language that continues to surprise and amaze with all its features.  I never realized it was as easy as providing an iterator to give a class iteration features.  Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>Ted, great Groovy stuff!  You gotta love a language that continues to surprise and amaze with all its features.  I never realized it was as easy as providing an iterator to give a class iteration features.  Thanks for the tip!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
