<?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: Does Scala have Java&#8217;s ternary operator?</title>
	<atom:link href="http://blog.tmorris.net/does-scala-have-javas-ternary-operator/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tmorris.net/does-scala-have-javas-ternary-operator/</link>
	<description>The weblog of Tony Morris</description>
	<pubDate>Tue, 06 Jan 2009 15:13:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: jherber</title>
		<link>http://blog.tmorris.net/does-scala-have-javas-ternary-operator/#comment-22342</link>
		<dc:creator>jherber</dc:creator>
		<pubDate>Fri, 07 Nov 2008 04:59:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/?p=375#comment-22342</guid>
		<description>anyone else care for the look of R's ifelse function?

def ifelse[U](c:Boolean, t_exp: =&#62;U, f_exp: =&#62;U) = if (c) t_exp else f_exp

val x = ifelse(condition, "true", "false")   // no parenthesis corner cases
val x = condition ? "true" &#124; "false"

unfortunately, scala doesn't infer the type on the partial :(

val t = ifelse( _:Boolean, b, c)</description>
		<content:encoded><![CDATA[<p>anyone else care for the look of R&#8217;s ifelse function?</p>
<p>def ifelse[U](c:Boolean, t_exp: =&gt;U, f_exp: =&gt;U) = if (c) t_exp else f_exp</p>
<p>val x = ifelse(condition, &#8220;true&#8221;, &#8220;false&#8221;)   // no parenthesis corner cases<br />
val x = condition ? &#8220;true&#8221; | &#8220;false&#8221;</p>
<p>unfortunately, scala doesn&#8217;t infer the type on the partial <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>val t = ifelse( _:Boolean, b, c)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Morris</title>
		<link>http://blog.tmorris.net/does-scala-have-javas-ternary-operator/#comment-21529</link>
		<dc:creator>Tony Morris</dc:creator>
		<pubDate>Wed, 29 Oct 2008 20:15:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/?p=375#comment-21529</guid>
		<description>Pawel, Yes it is needed. Not because of the terser syntax (I happen to prefer it though), but because it allows composition of the smaller parts.

e.g.
&lt;code&gt;val t = _ ? b &#124; c&lt;/code&gt; is a function that takes a boolean and returns the least common superclass of b and c. In other words 'if' should be a regular function (which the compiler optimises), not a language specialty. The bad habit here, is copying older languages without call-by-name semantics by making it a language feature.</description>
		<content:encoded><![CDATA[<p>Pawel, Yes it is needed. Not because of the terser syntax (I happen to prefer it though), but because it allows composition of the smaller parts.</p>
<p>e.g.<br />
<code>val t = _ ? b | c</code> is a function that takes a boolean and returns the least common superclass of b and c. In other words &#8216;if&#8217; should be a regular function (which the compiler optimises), not a language specialty. The bad habit here, is copying older languages without call-by-name semantics by making it a language feature.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pawel Badenski</title>
		<link>http://blog.tmorris.net/does-scala-have-javas-ternary-operator/#comment-21490</link>
		<dc:creator>Pawel Badenski</dc:creator>
		<pubDate>Wed, 29 Oct 2008 09:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/?p=375#comment-21490</guid>
		<description>And the big question is "do we really need it ?". "if a else b" is a nice Scala idiom, and in my opinion introducing "a ? b &#124; c" is just bringing old habits to a new environment. It doesn't really hurt in this case but I can resist the feeling it's some sort of a bad smell...</description>
		<content:encoded><![CDATA[<p>And the big question is &#8220;do we really need it ?&#8221;. &#8220;if a else b&#8221; is a nice Scala idiom, and in my opinion introducing &#8220;a ? b | c&#8221; is just bringing old habits to a new environment. It doesn&#8217;t really hurt in this case but I can resist the feeling it&#8217;s some sort of a bad smell&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erkki Lindpere</title>
		<link>http://blog.tmorris.net/does-scala-have-javas-ternary-operator/#comment-19360</link>
		<dc:creator>Erkki Lindpere</dc:creator>
		<pubDate>Mon, 13 Oct 2008 22:27:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/?p=375#comment-19360</guid>
		<description>Nice, why didn't I think of that?</description>
		<content:encoded><![CDATA[<p>Nice, why didn&#8217;t I think of that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ricky Clarkson</title>
		<link>http://blog.tmorris.net/does-scala-have-javas-ternary-operator/#comment-19271</link>
		<dc:creator>Ricky Clarkson</dc:creator>
		<pubDate>Mon, 13 Oct 2008 09:08:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/?p=375#comment-19271</guid>
		<description>Note that the operator precedence does not match Java's, so you'll have to parenthesise most calls to this.</description>
		<content:encoded><![CDATA[<p>Note that the operator precedence does not match Java&#8217;s, so you&#8217;ll have to parenthesise most calls to this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
