<?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>Anna Filina &#187; typing</title>
	<atom:link href="http://annafilina.com/blog/tag/typing/feed/" rel="self" type="application/rss+xml" />
	<link>http://annafilina.com/blog</link>
	<description>I fix stuff</description>
	<lastBuildDate>Wed, 04 Jan 2012 14:56:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AS3 Mystery: null, false, 0, &#8220;&#8221;, NaN</title>
		<link>http://annafilina.com/blog/as3-mystery-null-false-0-nan/</link>
		<comments>http://annafilina.com/blog/as3-mystery-null-false-0-nan/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 13:56:01 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[typing]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=228</guid>
		<description><![CDATA[This week I&#8217;ve been running unit tests and couldn&#8217;t understand why some of them were failing for no obvious reason. To understand why some expressions evaluated to true when they were supposed to be false. I know that I should be careful with null vs false values, but never could I have imagined that the<div><a href="http://annafilina.com/blog/as3-mystery-null-false-0-nan/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>This week I&#8217;ve been running unit tests and couldn&#8217;t understand why some of them were failing for no obvious reason. To understand why some expressions evaluated to true when they were supposed to be false. I know that I should be careful with null vs false values, but never could I have imagined that the Number 0 can be equal to an empty String!</p>
<p>I know that php&#8217;s empty() function is quite permissive, but I though AS3 was much more strict (with strict typing and all). And so I ran a different kind of test, where I checked these values in depth. Here is a table describing my results.</p>
<table border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<th> </th>
<th>null</th>
<th>false</th>
<th>0</th>
<th>&#8220;&#8221;</th>
<th>NaN</th>
</tr>
<tr>
<th>isNaN() </th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>true</td>
</tr>
<tr>
<th>== &#8220;&#8221;</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>=== &#8220;&#8221;</th>
<td> </td>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>== null</th>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>=== null</th>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>== 0</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>=== 0</th>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>== false</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>=== false</th>
<td> </td>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>is Number</th>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
<td>true</td>
</tr>
<tr>
<th>is String</th>
<td> </td>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>is Boolean</th>
<td> </td>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>is Object</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td>true</td>
</tr>
</tbody>
</table>
<p> You will notice that NaN is actually a Number and an Object, that 0 == &#8220;&#8221; == false and that false is actually an Object. There are quite a few surprises in there that will make me appreciate strict comparison.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/as3-mystery-null-false-0-nan/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>if (value is Object) problem</title>
		<link>http://annafilina.com/blog/if-value-is-object-problem/</link>
		<comments>http://annafilina.com/blog/if-value-is-object-problem/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 16:52:38 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[typing]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=138</guid>
		<description><![CDATA[To my knowledge, everything is AS3 an object. Functions, Strings, Arrays&#8230;
So how do we check if our value is actually an Object? I had this problem in a for loop. I wanted to treat primitive types, Arrays and Objects differently. My first reaction was to test for Arrays, then for Objects and handle the rest<div><a href="http://annafilina.com/blog/if-value-is-object-problem/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>To my knowledge, everything is AS3 an object. Functions, Strings, Arrays&#8230;</p>
<p>So how do we check if our value is actually an Object? I had this problem in a for loop. I wanted to treat primitive types, Arrays and Objects differently. My first reaction was to test for Arrays, then for Objects and handle the rest in the else block. Well remember that if you check if a String is an Object, you&#8217;ll get a false positive.</p>
<h2>Solution</h2>
<pre class="brush:as3">var className:Object = getQualifiedClassName(value);
if (className == 'Object') {
    // do stuff here
}
else if (className == 'Array') {
    // do stuff here
}
else {
    // do stuff here
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/if-value-is-object-problem/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Working with types in AS3</title>
		<link>http://annafilina.com/blog/working-with-types-in-as3/</link>
		<comments>http://annafilina.com/blog/working-with-types-in-as3/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 17:31:16 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[typing]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/archives/19</guid>
		<description><![CDATA[ActionScript 3 is strong-typed, which is great to detect possible errors at compile-time. Here are a few tips for working with types.
Type wildcard
var someVar:*;
This is not recommended (can cause runtime errors) but is possible. I suggest using a common parent (DisplayObject, for example) whenever possible.
Type checking
if (someVar is MovieClip) {}
This is most useful. Example: getting<div><a href="http://annafilina.com/blog/working-with-types-in-as3/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>ActionScript 3 is strong-typed, which is great to detect possible errors at compile-time. Here are a few tips for working with types.</p>
<p>Type wildcard</p>
<pre class="brush:as3">var someVar:*;</pre>
<p>This is not recommended (can cause runtime errors) but is possible. I suggest using a common parent (DisplayObject, for example) whenever possible.</p>
<p>Type checking</p>
<pre class="brush:as3">if (someVar is MovieClip) {}</pre>
<p>This is most useful. Example: getting the list of MovieClip children from a parent MovieClip (you don&#8217;t want shapes and all). This line might prevent the whole app from blowing up in your face.</p>
<p>Type casting</p>
<pre class="brush:as3">var item:Object = ComboBox(event.currentTarget).selectedItem;</pre>
<p>This will prevent type-mismatch complile errors. The same applies to simple types, such as int and uint.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/working-with-types-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

