title: Aggregate: Seed with a null value
body: <p>I am trying to find some items, then get the closest one by vector distance. Sometimes <code>FindAll</code> doesn't return elements causing <code>Aggregate</code> to fail. I could check to see that the list does in fact contain something, but could I just seed the <code>Aggregate</code> with some value such as <code>null</code> somehow? I tried using null, but I get this error:</p>
  
  <blockquote>
    <p>The type arguments for method 'Enumerable.Aggregate(IEnumerable, TAccumulate, Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.</p>
  </blockquote>
  
  <p>Is there a way to run aggregate so that it returns either <code>AIBrain</code> or <code>null</code>?</p>
  
  <pre><code>public AIBrain Closest(AIAttack attack = null) {
    if (others.Count == 0) return null;
    return others
      .FindAll(item =&gt; attack != null ? attack.IsAttackable(item) : true)
      .Aggregate(null, (curr, item) =&gt; {
        float currDistance = Vector3.Distance(transform.position, curr.transform.position);
        float itemDistance = Vector3.Distance(transform.position, item.transform.position);
        return itemDistance &lt; currDistance ? item : curr;
      });
  }
  </code></pre>