title: Why does Iterables.find() in Guava throw NoSuchElementException, instead of returning null?
body: <p>I love Google Guava and use it a lot, but there is one method I always find me writing..</p>
  
  <pre><code> public static &lt;T&gt; T tryFind(Iterable&lt;T&gt; iterable, Predicate&lt;T&gt; predicate){
       for(T t : iterable){
           if(predicate.apply(t)){
                return t;
           }
       }
       return null;
    }
  </code></pre>
  
  <p>To me this seems to be a very useful addition to <code>Iterables</code> (also to <code>Iterators</code> for that matter), so I'm wondering why it's missing. Also, while I can see the point of having a method that throws <code>NoSuchElementException</code>, perhaps to distinguish between finding a null and not finding the element, that situation only comes up if the predicate you are using is</p>
  
  <pre><code>public boolean apply(T t){
       return t==null;
  }
  </code></pre>
  
  <p>which doesn't seem to be a common case.  </p>
  
  <p>So why did guava designers chose to have this behavior, instead of just returning null if it can't find it?  </p>
  
  <p>Here is the javadoc for [Iterables.find()][1]</p>
  
  <p>[1]: <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Iterables.html#find(java.lang.Iterable" rel="noreferrer">http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Iterables.html#find(java.lang.Iterable</a>, com.google.common.base.Predicate)</p>