<?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: Understanding Ruby blocks, Procs and methods</title>
	<atom:link href="http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/feed/" rel="self" type="application/rss+xml" />
	<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/</link>
	<description>Eli Bendersky's personal website</description>
	<lastBuildDate>Wed, 10 Mar 2010 17:32:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bryan</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-255705</link>
		<dc:creator>Bryan</dc:creator>
		<pubDate>Tue, 26 Jan 2010 22:00:22 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-255705</guid>
		<description>Hi there,

Nice article.

What I have a hard time with is knowing when to use a plain method and when to use a Proc-object.

Your thoughts ?

btw: 
Isn&#039;t the shortcut for Proc.new not simply proc instead of lambda which is something on it&#039;s own ?</description>
		<content:encoded><![CDATA[<p>Hi there,</p>
<p>Nice article.</p>
<p>What I have a hard time with is knowing when to use a plain method and when to use a Proc-object.</p>
<p>Your thoughts ?</p>
<p>btw:<br />
Isn&#8217;t the shortcut for Proc.new not simply proc instead of lambda which is something on it&#8217;s own ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimmi</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-255513</link>
		<dc:creator>jimmi</dc:creator>
		<pubDate>Tue, 26 Jan 2010 10:53:05 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-255513</guid>
		<description>Complex topics, simply presented.....
helps a lot, thanks.</description>
		<content:encoded><![CDATA[<p>Complex topics, simply presented&#8230;..<br />
helps a lot, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cipriano</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-227682</link>
		<dc:creator>cipriano</dc:creator>
		<pubDate>Fri, 20 Nov 2009 01:54:34 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-227682</guid>
		<description>Great post for someone that isn&#039;t new to programming, but new to ruby. I still don&#039;t understand the reason to write code this way, but I think that will become more apparent as I learn more about Ruby. Thanks!</description>
		<content:encoded><![CDATA[<p>Great post for someone that isn&#8217;t new to programming, but new to ruby. I still don&#8217;t understand the reason to write code this way, but I think that will become more apparent as I learn more about Ruby. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-195773</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Thu, 20 Aug 2009 15:27:48 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-195773</guid>
		<description>Thanks; definitely the best summary I&#039;ve found.  Either that, or my background on this stuff finally got to the point where it all makes sense when I see it written out :).

Wanted to second the point of Coffee_fan above; you don&#039;t use return to get out of blocks (unless you actually want to pop out of the enclosing method), but you can use break or next.  These are useful in different situations.  Also, break and next can both take arguments to return to the outer context, just like return.

@elliottcable: :)</description>
		<content:encoded><![CDATA[<p>Thanks; definitely the best summary I&#8217;ve found.  Either that, or my background on this stuff finally got to the point where it all makes sense when I see it written out <img src='http://eli.thegreenplace.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Wanted to second the point of Coffee_fan above; you don&#8217;t use return to get out of blocks (unless you actually want to pop out of the enclosing method), but you can use break or next.  These are useful in different situations.  Also, break and next can both take arguments to return to the outer context, just like return.</p>
<p>@elliottcable: <img src='http://eli.thegreenplace.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Biju Subhash</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-148669</link>
		<dc:creator>Biju Subhash</dc:creator>
		<pubDate>Sat, 27 Dec 2008 07:58:43 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-148669</guid>
		<description>Nice Post :D
Thank You</description>
		<content:encoded><![CDATA[<p>Nice Post <img src='http://eli.thegreenplace.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
Thank You</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-122376</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Thu, 12 Jun 2008 15:32:26 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-122376</guid>
		<description>Great article. Really cleared up a lot of my understanding about this topic!</description>
		<content:encoded><![CDATA[<p>Great article. Really cleared up a lot of my understanding about this topic!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andriy</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-112406</link>
		<dc:creator>Andriy</dc:creator>
		<pubDate>Tue, 26 Feb 2008 01:39:14 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-112406</guid>
		<description>Great explanation. Finally i understand &quot;how&quot; yield works.</description>
		<content:encoded><![CDATA[<p>Great explanation. Finally i understand &#8220;how&#8221; yield works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak Gole</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-98813</link>
		<dc:creator>Deepak Gole</dc:creator>
		<pubDate>Tue, 15 Jan 2008 07:28:30 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-98813</guid>
		<description>Hello If I want pass arguments to method (&amp;:center), then how to send it
class Symbol
    
    # A generalized conversion of a method name
    # to a proc that runs this method.
    #
    def to_proc
        lambda {&#124;x, *args&#124; x.send(self, *args)}
    end
    
end

# Viola !
words = %w(Jane, aara, multiko)
upcase_words = words.map(&amp;:center)</description>
		<content:encoded><![CDATA[<p>Hello If I want pass arguments to method (&amp;:center), then how to send it<br />
class Symbol</p>
<p>    # A generalized conversion of a method name<br />
    # to a proc that runs this method.<br />
    #<br />
    def to_proc<br />
        lambda {|x, *args| x.send(self, *args)}<br />
    end</p>
<p>end</p>
<p># Viola !<br />
words = %w(Jane, aara, multiko)<br />
upcase_words = words.map(&amp;:center)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cks2k2</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-91385</link>
		<dc:creator>cks2k2</dc:creator>
		<pubDate>Mon, 10 Dec 2007 06:10:37 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-91385</guid>
		<description># this doesn&#039;t (ArgumentError), because &amp;f 
# isn&#039;t really an argument - it&#039;s only there 
# to convert a block
contrived(25, lambda {&#124;x&#124; puts x})

I tried this on 1.8.6-25 but getting an ArgumentError(2 for 1).
Or am I the only getting this error?
I&#039;ve tried contrived( 25, Proc.new {&#124;x&#124; puts x}) but it&#039;s still not working.</description>
		<content:encoded><![CDATA[<p># this doesn&#8217;t (ArgumentError), because &amp;f<br />
# isn&#8217;t really an argument &#8211; it&#8217;s only there<br />
# to convert a block<br />
contrived(25, lambda {|x| puts x})</p>
<p>I tried this on 1.8.6-25 but getting an ArgumentError(2 for 1).<br />
Or am I the only getting this error?<br />
I&#8217;ve tried contrived( 25, Proc.new {|x| puts x}) but it&#8217;s still not working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: elliottcable</title>
		<link>http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/comment-page-1/#comment-89799</link>
		<dc:creator>elliottcable</dc:creator>
		<pubDate>Tue, 27 Nov 2007 21:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2006/04/18/understanding-ruby-blocks-procs-and-methods/#comment-89799</guid>
		<description>&lt;blockquote&gt;In addition to being way cooler a whopping two characters shorter&lt;/blockquote&gt;

Or, if you&#039;re really awesomely cool, you could do this instead:
&lt;code&gt;module Kernel
   alias λ proc # (U+03BB)
end

padd = λ {&#124;x, y&#124; puts x + y}
padd.call&lt;/code&gt;</description>
		<content:encoded><![CDATA[<blockquote><p>In addition to being way cooler a whopping two characters shorter</p></blockquote>
<p>Or, if you&#8217;re really awesomely cool, you could do this instead:<br />
<code>module Kernel<br />
   alias λ proc # (U+03BB)<br />
end</p>
<p>padd = λ {|x, y| puts x + y}<br />
padd.call</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
