title: Scala: behavior of filter on Iterator vs. List
body: <pre><code>$ scala
  Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79).
  Type in expressions to have them evaluated.
  Type :help for more information.
  
  scala&gt; Iterator(2,4,6)
  res0: Iterator[Int] = non-empty iterator
  
  scala&gt; res0.filter
  filter      filterNot
  
  scala&gt; res0.filter
                                             def filter(p: A =&gt; Boolean): Iterator[A]
  </code></pre>
  
  <p>// Given this definition of filter, I would expect the below expression (1) to work:</p>
  
  <pre><code>scala&gt; Iterator(2,4,6).filter(Set(1,2,3).contains).toSet
  res1: scala.collection.immutable.Set[Int] = Set(2)
  </code></pre>
  
  <p>// <strong>Question # 1:</strong> How does the below expression (2) work ? Where does it get the <code>A =&gt; Boolean</code> inference from ? I meant to ask, where's the Boolean coming from ?</p>
  
  <pre><code>scala&gt; Iterator(2,4,6).filter(Set(1,2,3)).toSet
  res2: scala.collection.immutable.Set[Int] = Set(2)
  </code></pre>
  
  <p>// <strong>Question # 2</strong>: Which one is better expression (1) vs (2) and why ?</p>
  
  <p>// Tried the same thing on List and I expected this to work.</p>
  
  <pre><code> scala&gt; List(2,4,6).filter(List(1,2,3).contains)
      res3: List[Int] = List(2)
  </code></pre>
  
  <p>// <strong>Question # 3:</strong> Why doesn't this work when it magically worked for Iterator ?</p>
  
  <pre><code>scala&gt;  List(2,4,6).filter(List(1,2,3))
  &lt;console&gt;:8: error: type mismatch;
   found   : Int(1)
   required: Boolean
                 List(2,4,6).filter(List(1,2,3))
  </code></pre>