<?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"
	>
<channel>
	<title>Comments on: Concisely operating with ternaries</title>
	<atom:link href="http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/feed/" rel="self" type="application/rss+xml" />
	<link>http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/</link>
	<description>Can you dig it man?</description>
	<pubDate>Mon, 13 Oct 2008 18:48:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Andy</title>
		<link>http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-61336</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Mon, 19 May 2008 14:40:57 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-61336</guid>
		<description>Ted- thanks for the example of the Elvis operator-- indeed, quite Groovy, man. If writing ternary style logic in Groovy, it's a total win!</description>
		<content:encoded><![CDATA[<p>Ted- thanks for the example of the Elvis operator&#8211; indeed, quite Groovy, man. If writing ternary style logic in Groovy, it&#8217;s a total win!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Grundlefleck</title>
		<link>http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-61316</link>
		<dc:creator>Grundlefleck</dc:creator>
		<pubDate>Mon, 19 May 2008 10:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-61316</guid>
		<description>Yes, I'm a moron who skim reads. Ignore.

:-D</description>
		<content:encoded><![CDATA[<p>Yes, I&#8217;m a moron who skim reads. Ignore.</p>
<p> <img src='http://thediscoblog.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Grundlefleck</title>
		<link>http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-61314</link>
		<dc:creator>Grundlefleck</dc:creator>
		<pubDate>Mon, 19 May 2008 10:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-61314</guid>
		<description>Sorry to burst your bubble, but Java has this operator too. Not sure how long though.
[code]

public class TernaryDemo{
  public static void main(String[] args){
    String location = null;
    
    String ternaryLocation = location == null? "DefaultLocation": location;
      
    System.out.println("Ternary selected location is: " + ternaryLocation);
  }
}

[/code]

java TernaryDemo
Ternary selected location is: DefaultLocation


~ Grundlefleck</description>
		<content:encoded><![CDATA[<p>Sorry to burst your bubble, but Java has this operator too. Not sure how long though.<br />
[code]</p>
<p>public class TernaryDemo{<br />
  public static void main(String[] args){<br />
    String location = null;</p>
<p>    String ternaryLocation = location == null? &#8220;DefaultLocation&#8221;: location;</p>
<p>    System.out.println(&#8221;Ternary selected location is: &#8221; + ternaryLocation);<br />
  }<br />
}</p>
<p>[/code]</p>
<p>java TernaryDemo<br />
Ternary selected location is: DefaultLocation</p>
<p>~ Grundlefleck</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pages tagged "laconic"</title>
		<link>http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-60982</link>
		<dc:creator>Pages tagged "laconic"</dc:creator>
		<pubDate>Sat, 17 May 2008 22:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-60982</guid>
		<description>[...] tagged laconicOwn a Wordpress blog? Make monetization easier with the WP Affiliate Pro plugin. Concisely operating with ternaries&#160;saved by 3 others  &#160;&#160;&#160;&#160;gunziscool bookmarked on 05/17/08 &#124; [...]</description>
		<content:encoded><![CDATA[<p>[...] tagged laconicOwn a Wordpress blog? Make monetization easier with the WP Affiliate Pro plugin. Concisely operating with ternaries&nbsp;saved by 3 others  &nbsp;&nbsp;&nbsp;&nbsp;gunziscool bookmarked on 05/17/08 | [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted Naleid</title>
		<link>http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-60942</link>
		<dc:creator>Ted Naleid</dc:creator>
		<pubDate>Sat, 17 May 2008 18:13:37 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2008/05/17/concisely-operating-with-ternaries/#comment-60942</guid>
		<description>Don't forget about the &lt;a href="http://groovy.codehaus.org/Operators#Operators-ElvisOperator%28%3F%3A%5C%29" rel="nofollow"&gt;"?:" Elvis operator&lt;/a&gt; (does it get any groovier than Elvis?).  It's essentially a shortened form of the ternary operator where if the first value evaluates to false, the expression will evaluate to the item after the operator.

So in the example you gave above, it can be reduced even further to:

this.location = location ?: DEFAULT_LOC_NAME

If "location" is null, this.location will be set to DEFAULT_LOC_NAME, otherwise, if location is not null this.location will be set to location's value.</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget about the <a href="http://groovy.codehaus.org/Operators#Operators-ElvisOperator%28%3F%3A%5C%29" rel="nofollow">&#8220;?:&#8221; Elvis operator</a> (does it get any groovier than Elvis?).  It&#8217;s essentially a shortened form of the ternary operator where if the first value evaluates to false, the expression will evaluate to the item after the operator.</p>
<p>So in the example you gave above, it can be reduced even further to:</p>
<p>this.location = location ?: DEFAULT_LOC_NAME</p>
<p>If &#8220;location&#8221; is null, this.location will be set to DEFAULT_LOC_NAME, otherwise, if location is not null this.location will be set to location&#8217;s value.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
