<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Lucid &#187; operator</title>
	<atom:link href="http://thelucid.com/tag/operator/feed/" rel="self" type="application/rss+xml" />
	<link>http://thelucid.com</link>
	<description>The Lightweight Ramblings of Jamie Hill</description>
	<lastBuildDate>Thu, 26 Jan 2012 13:52:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ruby Ternary operator re-written with Boolean operators</title>
		<link>http://thelucid.com/2007/08/23/ruby-ternary-operator-re-written-with-boolean-operators/</link>
		<comments>http://thelucid.com/2007/08/23/ruby-ternary-operator-re-written-with-boolean-operators/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 16:43:00 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[boolean]]></category>
		<category><![CDATA[operator]]></category>
		<category><![CDATA[ternary]]></category>

		<guid isPermaLink="false">http://8b9af4c0-38d3-444d-8072-94ec308fc3b2</guid>
		<description><![CDATA[Just noticed something interesting (well not that interesting). Ternary operators in Ruby can be re-written using Boolean operators e.g. method = object.respond_to?&#40;:foo&#41; ? :foo : :bar would become&#8230; method = object.respond_to?&#40;:foo&#41; &#38;&#38; :foo &#124;&#124; :bar Simply replace ? with &#038;&#038; and : with &#124;&#124; I don&#8217;t know if there is any performance gain here, anyone [...]]]></description>
			<content:encoded><![CDATA[<p>Just noticed something interesting (well not that interesting). Ternary operators in Ruby can be re-written using Boolean operators e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">method = object.<span style="color:#9900CC;">respond_to</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:foo</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#ff3333; font-weight:bold;">:foo</span> : <span style="color:#ff3333; font-weight:bold;">:bar</span></pre></div></div>

<p>would become&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">method = object.<span style="color:#9900CC;">respond_to</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:foo</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#ff3333; font-weight:bold;">:foo</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#ff3333; font-weight:bold;">:bar</span></pre></div></div>

<p>Simply replace <code>?</code> with <code>&#038;&#038;</code> and <code>:</code> with <code>||</code></p>
<p>I don&#8217;t know if there is any performance gain here, anyone care to investigate?</p>
]]></content:encoded>
			<wfw:commentRss>http://thelucid.com/2007/08/23/ruby-ternary-operator-re-written-with-boolean-operators/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

