<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to return multiple values from a method</title>
	<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/</link>
	<description>Because programming should be fun</description>
	<pubDate>Sat, 22 Nov 2008 05:20:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>

	<item>
		<title>By: Chris</title>
		<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-284</link>
		<author>Chris</author>
		<pubDate>Wed, 04 Jul 2007 07:02:48 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-284</guid>
					<description>This is also how MATLAB handles multiple outputs from functions. Pretty swish.</description>
		<content:encoded><![CDATA[<p>This is also how MATLAB handles multiple outputs from functions. Pretty swish.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-285</link>
		<author>Alex</author>
		<pubDate>Wed, 04 Jul 2007 18:46:10 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-285</guid>
					<description>That's pretty cool. It's a bit of a shame that you can't do:
do_whatever if a_method_to_insult_innocent_people
I guess you could do a_method_to_insult_innocent_people.first instead, although that seems a little ugly.</description>
		<content:encoded><![CDATA[<p>That&#8217;s pretty cool. It&#8217;s a bit of a shame that you can&#8217;t do:<br />
do_whatever if a_method_to_insult_innocent_people<br />
I guess you could do a_method_to_insult_innocent_people.first instead, although that seems a little ugly.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-286</link>
		<author>Frank</author>
		<pubDate>Thu, 05 Jul 2007 13:24:16 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-286</guid>
					<description>@Alex, 

Good observation. It's true that you have to be careful with statements like "do_whatever if a_method_to_insult_innocent_people" (since it will always return true). 

I don't dislike your solution (a_method_to_insult_innocent_people.first) but I think I would prefer :  a_method_to_insult_innocent_people[0]. It may feel "less ruby" but it has the advantage of being clear about what the return value really is (an array). On the other hand, if you use ".first", some could think that your method returned a custom object that contains a method named "first". Anyway, just a personal taste thing :)

Thanks for your comment</description>
		<content:encoded><![CDATA[<p>@Alex, </p>
<p>Good observation. It&#8217;s true that you have to be careful with statements like &#8220;do_whatever if a_method_to_insult_innocent_people&#8221; (since it will always return true). </p>
<p>I don&#8217;t dislike your solution (a_method_to_insult_innocent_people.first) but I think I would prefer :  a_method_to_insult_innocent_people[0]. It may feel &#8220;less ruby&#8221; but it has the advantage of being clear about what the return value really is (an array). On the other hand, if you use &#8220;.first&#8221;, some could think that your method returned a custom object that contains a method named &#8220;first&#8221;. Anyway, just a personal taste thing <img src='http://www.rubyfleebie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks for your comment</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: RSL</title>
		<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-287</link>
		<author>RSL</author>
		<pubDate>Thu, 05 Jul 2007 20:13:48 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-287</guid>
					<description>There's another reason that Alex's solution might be less than idea. If you're returning multiple values but only using one then you're probably better off with a different method.</description>
		<content:encoded><![CDATA[<p>There&#8217;s another reason that Alex&#8217;s solution might be less than idea. If you&#8217;re returning multiple values but only using one then you&#8217;re probably better off with a different method.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-288</link>
		<author>Alex</author>
		<pubDate>Thu, 05 Jul 2007 20:37:37 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-288</guid>
					<description>You are right RSL, although it was a convuluted example. A real world example of usage might be:
@insult_result = a_method_to_insult_innocent_people


In which case both values are used.

To be honest though, returning a hash would probably be nicer for everyone involved :).

Alex</description>
		<content:encoded><![CDATA[<p>You are right RSL, although it was a convuluted example. A real world example of usage might be:<br />
@insult_result = a_method_to_insult_innocent_people</p>
<p>In which case both values are used.</p>
<p>To be honest though, returning a hash would probably be nicer for everyone involved :).</p>
<p>Alex</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-289</link>
		<author>Alex</author>
		<pubDate>Thu, 05 Jul 2007 20:38:52 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-289</guid>
					<description>Sorry contrived, not convuluted (spelt wrong anyway).

Alex</description>
		<content:encoded><![CDATA[<p>Sorry contrived, not convuluted (spelt wrong anyway).</p>
<p>Alex</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Learning Ruby &#38; Rails - July edition &#124; www.neeraj.name</title>
		<link>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-334</link>
		<author>Learning Ruby &#38; Rails - July edition &#124; www.neeraj.name</author>
		<pubDate>Fri, 03 Aug 2007 13:30:36 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/how-to-return-multiple-values-from-a-method/#comment-334</guid>
					<description>[...] Returning multiple values from a method [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Returning multiple values from a method [&#8230;]</p>
]]></content:encoded>
				</item>
</channel>
</rss>
