<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: How to write case (switch) statements in Ruby</title>
	<atom:link href="http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/</link>
	<description>Brian Morearty's Blog</description>
	<lastBuildDate>Tue, 21 Feb 2012 17:43:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: jwoodlee</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-1562</link>
		<dc:creator><![CDATA[jwoodlee]]></dc:creator>
		<pubDate>Fri, 11 Nov 2011 14:06:33 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-1562</guid>
		<description><![CDATA[every since my first C class in college i have always munged the switch/case. Now that I now almost a dozen different languages. Its hopeless in remembering the syntax. Awesome post and example! Thanks.]]></description>
		<content:encoded><![CDATA[<p>every since my first C class in college i have always munged the switch/case. Now that I now almost a dozen different languages. Its hopeless in remembering the syntax. Awesome post and example! Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BT</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-1457</link>
		<dc:creator><![CDATA[BT]]></dc:creator>
		<pubDate>Tue, 22 Feb 2011 05:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-1457</guid>
		<description><![CDATA[&quot;Except you’re not that much like me so you didn’t. But I did.&quot; 

Ha!  thanks...]]></description>
		<content:encoded><![CDATA[<p>&#8220;Except you’re not that much like me so you didn’t. But I did.&#8221; </p>
<p>Ha!  thanks&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GetA</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-491</link>
		<dc:creator><![CDATA[GetA]]></dc:creator>
		<pubDate>Wed, 09 Sep 2009 21:51:01 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-491</guid>
		<description><![CDATA[this is awesome!]]></description>
		<content:encoded><![CDATA[<p>this is awesome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-479</link>
		<dc:creator><![CDATA[Joe]]></dc:creator>
		<pubDate>Tue, 11 Aug 2009 13:20:33 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-479</guid>
		<description><![CDATA[ahh, thank goodness for this post. The pickaxe was entirely opaque on this subject and I now know how to do if-else&#039;s neatly AND switches all with one structure.

Many thanks.]]></description>
		<content:encoded><![CDATA[<p>ahh, thank goodness for this post. The pickaxe was entirely opaque on this subject and I now know how to do if-else&#8217;s neatly AND switches all with one structure.</p>
<p>Many thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guido</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-468</link>
		<dc:creator><![CDATA[Guido]]></dc:creator>
		<pubDate>Fri, 24 Jul 2009 13:47:28 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-468</guid>
		<description><![CDATA[Thanks, this is awesome :)

Did I mention that I love Rails?]]></description>
		<content:encoded><![CDATA[<p>Thanks, this is awesome :)</p>
<p>Did I mention that I love Rails?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: spiralofhope</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-458</link>
		<dc:creator><![CDATA[spiralofhope]]></dc:creator>
		<pubDate>Tue, 30 Jun 2009 15:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-458</guid>
		<description><![CDATA[Thanks for the help with the array example.  It helped simplify my code.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the help with the array example.  It helped simplify my code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2009-06-15 &#171; Bloggitation</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-452</link>
		<dc:creator><![CDATA[links for 2009-06-15 &#171; Bloggitation]]></dc:creator>
		<pubDate>Mon, 15 Jun 2009 07:04:48 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-452</guid>
		<description><![CDATA[[...] How to write case (switch) statements in Ruby (tags: ruby programming) [...]]]></description>
		<content:encoded><![CDATA[<p>[...] How to write case (switch) statements in Ruby (tags: ruby programming) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samuel L.</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-166</link>
		<dc:creator><![CDATA[Samuel L.]]></dc:creator>
		<pubDate>Fri, 24 Apr 2009 11:16:46 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-166</guid>
		<description><![CDATA[Hey, cool tips. Perhaps I&#039;ll buy a glass of beer to that person from that chat who told me to visit your site :)]]></description>
		<content:encoded><![CDATA[<p>Hey, cool tips. Perhaps I&#8217;ll buy a glass of beer to that person from that chat who told me to visit your site :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raji</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-157</link>
		<dc:creator><![CDATA[raji]]></dc:creator>
		<pubDate>Tue, 21 Apr 2009 16:09:57 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-157</guid>
		<description><![CDATA[it worked. thank u sir]]></description>
		<content:encoded><![CDATA[<p>it worked. thank u sir</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Morearty</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-152</link>
		<dc:creator><![CDATA[Brian Morearty]]></dc:creator>
		<pubDate>Mon, 20 Apr 2009 16:47:22 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-152</guid>
		<description><![CDATA[Hi Raji,

I believe the problem is your case statement is comparing a string with an integer. Type &quot;value=gets&quot; into IRB and then type the number 1. You&#039;ll see that IRB tells you the result is the string &quot;1\n&quot;. 

To fix this, convert the value to an integer before comparing it to 1, 2, or 3:
  case value.to_i

Hope that helps!]]></description>
		<content:encoded><![CDATA[<p>Hi Raji,</p>
<p>I believe the problem is your case statement is comparing a string with an integer. Type &#8220;value=gets&#8221; into IRB and then type the number 1. You&#8217;ll see that IRB tells you the result is the string &#8220;1\n&#8221;. </p>
<p>To fix this, convert the value to an integer before comparing it to 1, 2, or 3:<br />
  case value.to_i</p>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raji</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-151</link>
		<dc:creator><![CDATA[raji]]></dc:creator>
		<pubDate>Mon, 20 Apr 2009 16:04:34 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-151</guid>
		<description><![CDATA[im going to create a adressbook in Ruby using XML.
My options are
1.List -  List the  XML file.
2.Add - Add an element into the XML file
3.Delete - Delete an element from the XML file
i want to put these three options in case statements and select one based on the user input.
                     value = gets  (receive input from the user)
                     case value
                         when 1: list (invoke list)
                         when 2: add (invoke add)
                         when 3: delete (invoke delete)
                     else    puts &quot;exit&quot;
  When i give input as 1,2,or 3 only else statement is  executed.
  Is the syntax is right?what corrections i have to do ?]]></description>
		<content:encoded><![CDATA[<p>im going to create a adressbook in Ruby using XML.<br />
My options are<br />
1.List &#8211;  List the  XML file.<br />
2.Add &#8211; Add an element into the XML file<br />
3.Delete &#8211; Delete an element from the XML file<br />
i want to put these three options in case statements and select one based on the user input.<br />
                     value = gets  (receive input from the user)<br />
                     case value<br />
                         when 1: list (invoke list)<br />
                         when 2: add (invoke add)<br />
                         when 3: delete (invoke delete)<br />
                     else    puts &#8220;exit&#8221;<br />
  When i give input as 1,2,or 3 only else statement is  executed.<br />
  Is the syntax is right?what corrections i have to do ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raji</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-142</link>
		<dc:creator><![CDATA[raji]]></dc:creator>
		<pubDate>Sun, 19 Apr 2009 04:39:27 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-142</guid>
		<description><![CDATA[hi how to use case statement when the input is from the user (i.e.)using gets.i tried  but it executes the default statement.]]></description>
		<content:encoded><![CDATA[<p>hi how to use case statement when the input is from the user (i.e.)using gets.i tried  but it executes the default statement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: enjoydiversity</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-93</link>
		<dc:creator><![CDATA[enjoydiversity]]></dc:creator>
		<pubDate>Mon, 23 Mar 2009 11:42:51 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-93</guid>
		<description><![CDATA[wow! nice. thanks.]]></description>
		<content:encoded><![CDATA[<p>wow! nice. thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans-Gunther Schmidt</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-78</link>
		<dc:creator><![CDATA[Hans-Gunther Schmidt]]></dc:creator>
		<pubDate>Wed, 11 Feb 2009 18:06:18 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-78</guid>
		<description><![CDATA[Great! I use this post quite often as reference because I always keep forgetting how to write that :-)]]></description>
		<content:encoded><![CDATA[<p>Great! I use this post quite often as reference because I always keep forgetting how to write that :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Morearty</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-8</link>
		<dc:creator><![CDATA[Brian Morearty]]></dc:creator>
		<pubDate>Tue, 06 May 2008 14:29:36 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-8</guid>
		<description><![CDATA[Great question, Rashantha. I assume you mean in a Rails View. The trick is to use %=, not %. Here&#039;s an example:

&lt;code&gt;&lt;%=
&#160;&#160;case @results
&#160;&#160;when nil then &quot;No results&quot;
&#160;&#160;else @results.join &quot;, &quot;
&#160;&#160;end
%&gt;&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>Great question, Rashantha. I assume you mean in a Rails View. The trick is to use %=, not %. Here&#8217;s an example:</p>
<p><code>&lt;%=<br />
&nbsp;&nbsp;case @results<br />
&nbsp;&nbsp;when nil then "No results"<br />
&nbsp;&nbsp;else @results.join ", "<br />
&nbsp;&nbsp;end<br />
%&gt;</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rashantha</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-7</link>
		<dc:creator><![CDATA[rashantha]]></dc:creator>
		<pubDate>Mon, 05 May 2008 19:57:15 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-7</guid>
		<description><![CDATA[can you use a case in a view? if so how?]]></description>
		<content:encoded><![CDATA[<p>can you use a case in a view? if so how?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anton</title>
		<link>http://ilikestuffblog.com/2008/04/15/how-to-write-case-switch-statements-in-ruby/#comment-6</link>
		<dc:creator><![CDATA[Anton]]></dc:creator>
		<pubDate>Sat, 19 Apr 2008 03:50:38 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=5#comment-6</guid>
		<description><![CDATA[Super! I just find this info yesterday. Very useful, thank you!]]></description>
		<content:encoded><![CDATA[<p>Super! I just find this info yesterday. Very useful, thank you!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

