<?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: How to pass the current binding&#8217;s block to some other method?</title>
	<atom:link href="http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/feed/" rel="self" type="application/rss+xml" />
	<link>http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/</link>
	<description>Covering Software Development with Ruby and FXRuby</description>
	<lastBuildDate>Wed, 27 Apr 2011 21:18:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: Lyle</title>
		<link>http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/comment-page-1/#comment-7948</link>
		<dc:creator>Lyle</dc:creator>
		<pubDate>Fri, 09 Feb 2007 00:37:04 +0000</pubDate>
		<guid isPermaLink="false">http://lylejohnson.name/blog/?p=177#comment-7948</guid>
		<description>@Mauricio: OK, I now see that the method that you and Phrogz were recommending does work, at least with a little sample program I wrote. For some reason I didn&#039;t think that it was working properly in my &quot;real&quot; code; I need to go back and see what I was doing differently.

@Brian: Joel VanderWerf (from the ML) suggested a similar approach, but just doing another &quot;yield self&quot; in the block instead of using &lt;code&gt;block.call(self)&lt;/code&gt;. I think either one should work similarly.</description>
		<content:encoded><![CDATA[<p>@Mauricio: OK, I now see that the method that you and Phrogz were recommending does work, at least with a little sample program I wrote. For some reason I didn&#8217;t think that it was working properly in my &#8220;real&#8221; code; I need to go back and see what I was doing differently.</p>
<p>@Brian: Joel VanderWerf (from the ML) suggested a similar approach, but just doing another &#8220;yield self&#8221; in the block instead of using <code>block.call(self)</code>. I think either one should work similarly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lyle</title>
		<link>http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/comment-page-1/#comment-7947</link>
		<dc:creator>Lyle</dc:creator>
		<pubDate>Fri, 09 Feb 2007 00:23:57 +0000</pubDate>
		<guid isPermaLink="false">http://lylejohnson.name/blog/?p=177#comment-7947</guid>
		<description>@Aaron (and mfp): I was looking for some way that doesn&#039;t require me to modify the original source code for &lt;code&gt;try()&lt;/code&gt;.

@Brian: Good idea! I think that should do the trick.</description>
		<content:encoded><![CDATA[<p>@Aaron (and mfp): I was looking for some way that doesn&#8217;t require me to modify the original source code for <code>try()</code>.</p>
<p>@Brian: Good idea! I think that should do the trick.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/comment-page-1/#comment-7946</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Fri, 09 Feb 2007 00:13:08 +0000</pubDate>
		<guid isPermaLink="false">http://lylejohnson.name/blog/?p=177#comment-7946</guid>
		<description>could your &quot;new&quot; try method just be something like:
&lt;code&gt;
def try(hash,&amp;block)
    if block
       old_try(hash[:x], hash[:y], hash[:z] ) { &#124;self&#124; block.call(self) }
    else
        old_try(hash[:x], hash[:y], hash[:z])
    end
end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>could your &#8220;new&#8221; try method just be something like:<br />
<code><br />
def try(hash,&amp;block)<br />
    if block<br />
       old_try(hash[:x], hash[:y], hash[:z] ) { |self| block.call(self) }<br />
    else<br />
        old_try(hash[:x], hash[:y], hash[:z])<br />
    end<br />
end<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mfp</title>
		<link>http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/comment-page-1/#comment-7945</link>
		<dc:creator>mfp</dc:creator>
		<pubDate>Fri, 09 Feb 2007 00:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://lylejohnson.name/blog/?p=177#comment-7945</guid>
		<description>forgot to say that the &amp;Proc.new thing also works, but &amp;block  is better and does what you want</description>
		<content:encoded><![CDATA[<p>forgot to say that the &amp;Proc.new thing also works, but &amp;block  is better and does what you want</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mfp</title>
		<link>http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/comment-page-1/#comment-7944</link>
		<dc:creator>mfp</dc:creator>
		<pubDate>Fri, 09 Feb 2007 00:05:34 +0000</pubDate>
		<guid isPermaLink="false">http://lylejohnson.name/blog/?p=177#comment-7944</guid>
		<description>As Phrogz showed in the ML:

&lt;code&gt;
# unmodified
def try(x, y, z)
&#160;&#160;(yield * y) if block_given?
end
# ^^^^

alias old_try try

def try(hash, &amp;block)
&#160;&#160;old_try(*hash.values_at(:a, :b, :c), &amp;block)
end

try(:a =&gt; 1, :b =&gt; 5, :c =&gt; 3) { &quot;foo&quot; }           # =&gt; &quot;foofoofoofoofoo&quot;
RUBY_VERSION                                       # =&gt; &quot;1.8.5&quot;
&lt;/code&gt; </description>
		<content:encoded><![CDATA[<p>As Phrogz showed in the ML:</p>
<p><code><br />
# unmodified<br />
def try(x, y, z)<br />
&nbsp;&nbsp;(yield * y) if block_given?<br />
end<br />
# ^^^^</p>
<p>alias old_try try</p>
<p>def try(hash, &amp;block)<br />
&nbsp;&nbsp;old_try(*hash.values_at(:a, :b, :c), &amp;block)<br />
end</p>
<p>try(:a =&gt; 1, :b =&gt; 5, :c =&gt; 3) { "foo" }           # =&gt; "foofoofoofoofoo"<br />
RUBY_VERSION                                       # =&gt; "1.8.5"<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Pfeifer</title>
		<link>http://lylejohnson.name/blog/2007/02/08/how-to-pass-the-current-bindings-block-to-some-other-method/comment-page-1/#comment-7943</link>
		<dc:creator>Aaron Pfeifer</dc:creator>
		<pubDate>Thu, 08 Feb 2007 23:46:33 +0000</pubDate>
		<guid isPermaLink="false">http://lylejohnson.name/blog/?p=177#comment-7943</guid>
		<description>I could be misinterpreting your question, but do you mean something like this?

&lt;code&gt;
alias old_try try
def try(hash, &amp;block)
  old_try(hash[:x], hash[:y], hash[:z], &amp;block)
end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I could be misinterpreting your question, but do you mean something like this?</p>
<p><code><br />
alias old_try try<br />
def try(hash, &amp;block)<br />
  old_try(hash[:x], hash[:y], hash[:z], &amp;block)<br />
end<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>

