<?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: Programming Style: Two Booleans, Three Possible Cases</title>
	<atom:link href="http://www.jamiephelps.com/all/programming-style-two-booleans-three-possible-cases/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jamiephelps.com/all/programming-style-two-booleans-three-possible-cases</link>
	<description>Proving the sunshine since 1980.</description>
	<lastBuildDate>Sat, 06 Feb 2010 01:07:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: David A Teare</title>
		<link>http://www.jamiephelps.com/all/programming-style-two-booleans-three-possible-cases/comment-page-1#comment-119</link>
		<dc:creator>David A Teare</dc:creator>
		<pubDate>Fri, 26 Sep 2008 23:55:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamiephelps.com/?p=97#comment-119</guid>
		<description>&lt;p&gt;If foo &amp;&amp; bar are both false, your first example will execute the else clause, which you comment is &quot;do bar-only stuff&quot;, which is false.&lt;/p&gt;

&lt;p&gt;I think you needed an extra &#039;else if&#039; clause.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If foo &amp;&amp; bar are both false, your first example will execute the else clause, which you comment is &#8220;do bar-only stuff&#8221;, which is false.</p>

<p>I think you needed an extra &#8216;else if&#8217; clause.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Hughes</title>
		<link>http://www.jamiephelps.com/all/programming-style-two-booleans-three-possible-cases/comment-page-1#comment-117</link>
		<dc:creator>Mark Hughes</dc:creator>
		<pubDate>Thu, 25 Sep 2008 14:27:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.jamiephelps.com/?p=97#comment-117</guid>
		<description>&lt;p&gt;If foo and bar are set by logically related tests, there&#039;s likely some common value you can use for them both. Lacking that common value, I&#039;d do this:&lt;/p&gt;

&lt;p&gt;NSInteger choice = (foo ? 1 : 0) &#124; (bar ? 2 : 0);
switch (choice) {
  case 0:
    // nothing
    break;
  case 1:
    // foo
    break;
  case 2:
    // bar
    break;
  case 3:
    // foo and bar
    break;
  default:
    NSAssert1(NO, @&quot;Invalid choice %d&quot;, choice);
}&lt;/p&gt;

&lt;p&gt;This makes it instantly clear that I&#039;ve covered all possible choices; I have to stop and think about the nested if statements every time I come by that code.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If foo and bar are set by logically related tests, there&#8217;s likely some common value you can use for them both. Lacking that common value, I&#8217;d do this:</p>

<p>NSInteger choice = (foo ? 1 : 0) | (bar ? 2 : 0);
switch (choice) {
  case 0:
    // nothing
    break;
  case 1:
    // foo
    break;
  case 2:
    // bar
    break;
  case 3:
    // foo and bar
    break;
  default:
    NSAssert1(NO, @&#8221;Invalid choice %d&#8221;, choice);
}</p>

<p>This makes it instantly clear that I&#8217;ve covered all possible choices; I have to stop and think about the nested if statements every time I come by that code.</p>]]></content:encoded>
	</item>
</channel>
</rss>
