<?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: When to check for null</title>
	<atom:link href="http://www.geekality.net/2009/01/15/when-to-check-for-null/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekality.net/2009/01/15/when-to-check-for-null/</link>
	<description>With a hint of Social Ineptitude</description>
	<lastBuildDate>Wed, 25 Aug 2010 13:50:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: <img src='http://www.geekality.net/wp-content/plugins/rpx/images/openid.png'/> Torleif</title>
		<link>http://www.geekality.net/2009/01/15/when-to-check-for-null/#comment-431</link>
		<dc:creator><img src='http://www.geekality.net/wp-content/plugins/rpx/images/openid.png'/> Torleif</dc:creator>
		<pubDate>Sat, 15 May 2010 11:14:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=48#comment-431</guid>
		<description>Seen it and tried to use it a bit. For example when I make things that returns iterators or arrays I try to always return empty ones instead of null. 

The colon-operator in Delphi Prism looks quite nice! In C# you have the ??-operator which is not as smooth, but still helps a bit with null checks. 

Instead of doing:

&lt;code lang=&quot;csharp&quot;&gt;var something = possibly_null != null ? possibly_null : alternative_if_null;&lt;/code&gt;

You can shorten it to:

&lt;code lang=&quot;csharp&quot;&gt;var something = possibly_null ?? alternative_if_null;&lt;/code&gt;

So if you had an object to represent a null or empty object you could do like this:

&lt;code lang=&quot;csharp&quot;&gt;var something = (some_container ?? Container.Empty).SomeProperty;&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Seen it and tried to use it a bit. For example when I make things that returns iterators or arrays I try to always return empty ones instead of null. </p>
<p>The colon-operator in Delphi Prism looks quite nice! In C# you have the ??-operator which is not as smooth, but still helps a bit with null checks. </p>
<p>Instead of doing:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var something <span style="color: #008000;">=</span> possibly_null <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">?</span> possibly_null <span style="color: #008000;">:</span> alternative_if_null<span style="color: #008000;">;</span></div></div>
<p>You can shorten it to:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var something <span style="color: #008000;">=</span> possibly_null <span style="color: #008000;">??</span> alternative_if_null<span style="color: #008000;">;</span></div></div>
<p>So if you had an object to represent a null or empty object you could do like this:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var something <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>some_container <span style="color: #008000;">??</span> Container<span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SomeProperty</span><span style="color: #008000;">;</span></div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: <img src='http://www.geekality.net/wp-content/plugins/rpx/images/openid.png'/> Vegar</title>
		<link>http://www.geekality.net/2009/01/15/when-to-check-for-null/#comment-4</link>
		<dc:creator><img src='http://www.geekality.net/wp-content/plugins/rpx/images/openid.png'/> Vegar</dc:creator>
		<pubDate>Mon, 21 Sep 2009 10:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=48#comment-4</guid>
		<description>Have you seen the &lt;a href=&quot;http://en.wikipedia.org/wiki/Null_Object_pattern&quot; rel=&quot;nofollow&quot;&gt;&#039;Null object pattern&#039; &lt;/a&gt; ? Haven&#039;t tried it out my self, but it would reduce amount of null-checking.

And then there is the &lt;a href=&quot;http://prismwiki.codegear.com/en/Colon_Operator&quot; rel=&quot;nofollow&quot;&gt;colon-operator&#039;&lt;/a&gt; in Delphi Prism.</description>
		<content:encoded><![CDATA[<p>Have you seen the <a href="http://en.wikipedia.org/wiki/Null_Object_pattern" rel="nofollow">&#8216;Null object pattern&#8217; </a> ? Haven&#8217;t tried it out my self, but it would reduce amount of null-checking.</p>
<p>And then there is the <a href="http://prismwiki.codegear.com/en/Colon_Operator" rel="nofollow">colon-operator&#8217;</a> in Delphi Prism.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
