title: Why do ImmutableList.of() and friends prohibit null elements?
body: <p>Summary pretty much says it all.  Here's the relevant snippet of code in <code>ImmutableList.createFromIterable()</code>:</p>
  
  <pre><code>  if (element == null) {
      throw new NullPointerException("at index " + index);
    }
  </code></pre>
  
  <p>I've run into this several times and can't see why a general-purpose library function should impose this limitation.</p>
  
  <p>Edit 1: by "general-purpose", I'd be happy with 95% of cases.  But I don't think I've written 100 calls to <code>ImmutableList.of()</code> yet, and have been bitten by this more than once.  Maybe I'm an outlier, though.  :)</p>
  
  <p>Edit 2: I guess my big complaint is that this creates a "hiccup" when interacting with standard <code>java.util</code> collections.  As you pointed out in your talk, problems with <code>null</code>s in collections can show up far away from where those nulls were inserted.  But if I have a long chain of code that puts nulls in a standard collection at one end and handles them properly at the other, then I'm unable to substitute a google collections class at any point along the way, because it'll immediately throw a <code>NullPointerException</code>.</p>