<?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: LINQ query operators and null lists</title>
	<atom:link href="http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/</link>
	<description>Strong opinions, weakly held</description>
	<lastBuildDate>Tue, 18 Jun 2013 19:00:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Wes McClure</title>
		<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/#comment-2067</link>
		<dc:creator>Wes McClure</dc:creator>
		<pubDate>Thu, 10 Dec 2009 06:09:53 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/12/08/linq-query-operators-and-null-lists.aspx#comment-2067</guid>
		<description>Yeah, my biggest pet peeve is ForEach exploding with null sources... why not just ignore it?  I try to always silently ignore null sources in extension methods unless it really doesn&#039;t make sense.  

Wouldn&#039;t it be nice if regular instance methods worked like python by taking the instance as a parameter so we could silently deal with nulls there too!</description>
		<content:encoded><![CDATA[<p>Yeah, my biggest pet peeve is ForEach exploding with null sources&#8230; why not just ignore it?  I try to always silently ignore null sources in extension methods unless it really doesn&#8217;t make sense.  </p>
<p>Wouldn&#8217;t it be nice if regular instance methods worked like python by taking the instance as a parameter so we could silently deal with nulls there too!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: superbecio</title>
		<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/#comment-2066</link>
		<dc:creator>superbecio</dc:creator>
		<pubDate>Wed, 09 Dec 2009 15:10:15 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/12/08/linq-query-operators-and-null-lists.aspx#comment-2066</guid>
		<description>I don&#039;t agree with the fact that methods returning collections should never return null, rather I prefer to use that special value as a signal for user canceled operations.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t agree with the fact that methods returning collections should never return null, rather I prefer to use that special value as a signal for user canceled operations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bogardj</title>
		<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/#comment-2065</link>
		<dc:creator>bogardj</dc:creator>
		<pubDate>Wed, 09 Dec 2009 14:19:15 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/12/08/linq-query-operators-and-null-lists.aspx#comment-2065</guid>
		<description>@Tommy, @Mike

Nice!  Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>@Tommy, @Mike</p>
<p>Nice!  Thanks for the tip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/#comment-2064</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 09 Dec 2009 13:44:44 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/12/08/linq-query-operators-and-null-lists.aspx#comment-2064</guid>
		<description>Save yourself a few lines of code by using a null-coalescing operator

return source ?? Enumerable.Empty&lt;TSource&gt;();</description>
		<content:encoded><![CDATA[<p>Save yourself a few lines of code by using a null-coalescing operator</p>
<p>return source ?? Enumerable.Empty<tsource>();</tsource></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tommy Carlier</title>
		<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/#comment-2063</link>
		<dc:creator>Tommy Carlier</dc:creator>
		<pubDate>Wed, 09 Dec 2009 13:42:14 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/12/08/linq-query-operators-and-null-lists.aspx#comment-2063</guid>
		<description>You could make that shorter by using the coalescing operator:

public static IEnumerable&lt;TSource&gt; NullToEmpty&lt;TSource&gt;(
  this IEnumerable&lt;TSource&gt; source)
{
    return source ?? Enumerable.Empty&lt;TSource&gt;();
}</description>
		<content:encoded><![CDATA[<p>You could make that shorter by using the coalescing operator:</p>
<p>public static IEnumerable<tsource> NullToEmpty</tsource><tsource>(<br />
  this IEnumerable</tsource><tsource> source)<br />
{<br />
    return source ?? Enumerable.Empty</tsource><tsource>();<br />
}</tsource></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vitaly Stakhov</title>
		<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/#comment-2062</link>
		<dc:creator>Vitaly Stakhov</dc:creator>
		<pubDate>Wed, 09 Dec 2009 06:41:16 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/12/08/linq-query-operators-and-null-lists.aspx#comment-2062</guid>
		<description>Conceptually you&#039;re trying to see if there is an element in &#039;null&#039; collection. Sometimes it&#039;s like division by zero.

If Microsoft ignored null collections, that would be similar to mark all classes in the project as [Serializable] (yes, there are benefits - you don&#039;t get SerializationException, but objects that are not expected to be serialized actually will be).

So, my point is to leave constraints as tough as possible. Anyway, there is always a choice either to define/use NullOrEmpty or not. If nulls were ignored by extension methods the choice would not exist.

There could be an option in linq inself to ignore or not though.</description>
		<content:encoded><![CDATA[<p>Conceptually you&#8217;re trying to see if there is an element in &#8216;null&#8217; collection. Sometimes it&#8217;s like division by zero.</p>
<p>If Microsoft ignored null collections, that would be similar to mark all classes in the project as [Serializable] (yes, there are benefits &#8211; you don&#8217;t get SerializationException, but objects that are not expected to be serialized actually will be).</p>
<p>So, my point is to leave constraints as tough as possible. Anyway, there is always a choice either to define/use NullOrEmpty or not. If nulls were ignored by extension methods the choice would not exist.</p>
<p>There could be an option in linq inself to ignore or not though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Farrell</title>
		<link>http://lostechies.com/jimmybogard/2009/12/08/linq-query-operators-and-null-lists/#comment-2061</link>
		<dc:creator>John Farrell</dc:creator>
		<pubDate>Wed, 09 Dec 2009 05:00:35 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jimmy_bogard/archive/2009/12/08/linq-query-operators-and-null-lists.aspx#comment-2061</guid>
		<description>Nice, this the most useful 4 lines of code I&#039;ve seen in a while.</description>
		<content:encoded><![CDATA[<p>Nice, this the most useful 4 lines of code I&#8217;ve seen in a while.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
