<?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: Playing with language: Inlined fromMaybe</title>
	<atom:link href="http://ajaxian.com/archives/playing-with-language-inlined-frommaybe/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/playing-with-language-inlined-frommaybe</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: Tim Cooijmans</title>
		<link>http://ajaxian.com/archives/playing-with-language-inlined-frommaybe/comment-page-1#comment-261835</link>
		<dc:creator>Tim Cooijmans</dc:creator>
		<pubDate>Wed, 05 Mar 2008 10:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3394#comment-261835</guid>
		<description>If a variable named &#039;products&#039; is a boolean, you have other things to worry about.</description>
		<content:encoded><![CDATA[<p>If a variable named &#8216;products&#8217; is a boolean, you have other things to worry about.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wralias</title>
		<link>http://ajaxian.com/archives/playing-with-language-inlined-frommaybe/comment-page-1#comment-261786</link>
		<dc:creator>wralias</dc:creator>
		<pubDate>Tue, 04 Mar 2008 00:53:16 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3394#comment-261786</guid>
		<description>&lt;blockquote&gt;&quot;the method should define what values it expects the user to supply it with&quot;&lt;/blockquote&gt;
I wholeheartedly agree.  Something like this: 
&lt;code&gt;
/**
* @param {Array} a
* ...
*/
var thing= function(a, b, c) {
  var a = typeof a != &quot;object&quot; &amp;&amp; typeof a.length != &quot;number&quot; ? [] : a;
  ...
}
&lt;/code&gt;
...might be all the stylin&#039; you need!</description>
		<content:encoded><![CDATA[<blockquote><p>&#8220;the method should define what values it expects the user to supply it with&#8221;</p></blockquote>
<p>I wholeheartedly agree.  Something like this:<br />
<code><br />
/**<br />
* @param {Array} a<br />
* ...<br />
*/<br />
var thing= function(a, b, c) {<br />
  var a = typeof a != "object" &amp;&amp; typeof a.length != "number" ? [] : a;<br />
  ...<br />
}<br />
</code><br />
&#8230;might be all the stylin&#8217; you need!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://ajaxian.com/archives/playing-with-language-inlined-frommaybe/comment-page-1#comment-261776</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 03 Mar 2008 17:52:32 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3394#comment-261776</guid>
		<description>@wralias: The method should define what values it expects the user to supply it with. If it specifies products to be an array or null, then this is an elegant and complete solution. If it allows products to be a boolean, then it is an incomplete solution. It all depends on how you are planning to allow your methods to be used. Otherwise it&#039;s just garbage-in garbage-out.</description>
		<content:encoded><![CDATA[<p>@wralias: The method should define what values it expects the user to supply it with. If it specifies products to be an array or null, then this is an elegant and complete solution. If it allows products to be a boolean, then it is an incomplete solution. It all depends on how you are planning to allow your methods to be used. Otherwise it&#8217;s just garbage-in garbage-out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wralias</title>
		<link>http://ajaxian.com/archives/playing-with-language-inlined-frommaybe/comment-page-1#comment-261761</link>
		<dc:creator>wralias</dc:creator>
		<pubDate>Mon, 03 Mar 2008 14:41:39 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3394#comment-261761</guid>
		<description>This seems like a nice way to write less code - on the other hand, in JavaScript at least, you are better served by type checking.  In the example...
&lt;code&gt;var count = (products &#124;&#124; []).length;&lt;/code&gt;
... it is quite possible that products could be a boolean value of true, in which case that expression will try to get the length property on a boolean value, which will throw an error.  Maybe the examples provided are a good way to write less code - but less is not always better.</description>
		<content:encoded><![CDATA[<p>This seems like a nice way to write less code &#8211; on the other hand, in JavaScript at least, you are better served by type checking.  In the example&#8230;<br />
<code>var count = (products || []).length;</code><br />
&#8230; it is quite possible that products could be a boolean value of true, in which case that expression will try to get the length property on a boolean value, which will throw an error.  Maybe the examples provided are a good way to write less code &#8211; but less is not always better.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

