<?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: Flexible If Syntax</title>
	<atom:link href="http://jacksondunstan.com/articles/422/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/422</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Mon, 14 May 2012 17:02:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: skyboy</title>
		<link>http://jacksondunstan.com/articles/422/comment-page-1#comment-761</link>
		<dc:creator>skyboy</dc:creator>
		<pubDate>Fri, 06 Aug 2010 18:34:54 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=422#comment-761</guid>
		<description>i&#039;d like to point out that nicolas is wrong; the &amp;&amp; operator evaluates both operands if the first one is true, but only the first if it is false. the &#124;&#124; operator on the other hand would do what he said.

but for usefulness of the comma operator, in var-statements

&lt;pre lang=&quot;actionscript3&quot;&gt;
var a:int = 15, b:Number, d:uint = uint(-1);
&lt;/pre&gt;

and if you don&#039;t want to use the braces in a short if-block

&lt;pre lang=&quot;actionscript3&quot;&gt;
if (value) func1(), func2(); // func1 is called, then func2 is called if value is true
&lt;/pre&gt;

though there&#039;s hardly a use for it inside the if-statement</description>
		<content:encoded><![CDATA[<p>i&#8217;d like to point out that nicolas is wrong; the &amp;&amp; operator evaluates both operands if the first one is true, but only the first if it is false. the || operator on the other hand would do what he said.</p>
<p>but for usefulness of the comma operator, in var-statements</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> a<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">15</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">d</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #004993;">uint</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>and if you don&#8217;t want to use the braces in a short if-block</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000000;">&#41;</span> func1<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> func2<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// func1 is called, then func2 is called if value is true</span></pre></div></div>

<p>though there&#8217;s hardly a use for it inside the if-statement</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://jacksondunstan.com/articles/422/comment-page-1#comment-364</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Tue, 10 Nov 2009 15:40:08 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=422#comment-364</guid>
		<description>If statements are processed until a true statement is found, that is why one should put the simpler computations first.
&lt;pre&gt;
if (simpleComputation() &amp;&amp; complexComputation())
&lt;/pre&gt;

If simpleCompuation turns out to be true, the complexComputation won’t even be made.</description>
		<content:encoded><![CDATA[<p>If statements are processed until a true statement is found, that is why one should put the simpler computations first.</p>
<pre>
if (simpleComputation() &amp;&amp; complexComputation())
</pre>
<p>If simpleCompuation turns out to be true, the complexComputation won’t even be made.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dVyper</title>
		<link>http://jacksondunstan.com/articles/422/comment-page-1#comment-349</link>
		<dc:creator>dVyper</dc:creator>
		<pubDate>Tue, 03 Nov 2009 16:48:31 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=422#comment-349</guid>
		<description>What an interesting discovery! Not too useful perhaps (unless you really like obfuscated code) but still cool to know :-)</description>
		<content:encoded><![CDATA[<p>What an interesting discovery! Not too useful perhaps (unless you really like obfuscated code) but still cool to know :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/422/comment-page-1#comment-346</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Mon, 02 Nov 2009 17:40:25 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=422#comment-346</guid>
		<description>Yes, but it&#039;s important to remember that all of the operands are evaluated. Consider this:

&lt;pre lang=&quot;actionscript3&quot;&gt;
var x:int = 0;
if (x++, x++, x++)
{
}
trace(x);
&lt;/pre&gt;

Since each &lt;tt&gt;x++&lt;/tt&gt; is evaluated, the value of &lt;tt&gt;x&lt;/tt&gt; is 3 at the end. The value of &lt;tt&gt;x&lt;/tt&gt; is &lt;em&gt;not&lt;/em&gt; 1 like you would expect if you thought that only the last operand was even considered.</description>
		<content:encoded><![CDATA[<p>Yes, but it&#8217;s important to remember that all of the operands are evaluated. Consider this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">++,</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">++,</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>Since each <tt>x++</tt> is evaluated, the value of <tt>x</tt> is 3 at the end. The value of <tt>x</tt> is <em>not</em> 1 like you would expect if you thought that only the last operand was even considered.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin</title>
		<link>http://jacksondunstan.com/articles/422/comment-page-1#comment-344</link>
		<dc:creator>Valentin</dc:creator>
		<pubDate>Mon, 02 Nov 2009 10:25:06 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=422#comment-344</guid>
		<description>So, the conclusion is that only the last value is used.</description>
		<content:encoded><![CDATA[<p>So, the conclusion is that only the last value is used.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

