title: Confused about function literals
body: <p>Scala newbie here.</p>
  
  <p>I have a Set defined and declared as follows:</p>
  
  <pre><code>var g = Set(1,2,3)
  </code></pre>
  
  <p>Now I want to print out each element of the Set as follows using a function literal:</p>
  
  <pre><code>scala&gt; g.foreach(s =&gt; println(s))
  1
  2
  3
  </code></pre>
  
  <p>All is good.</p>
  
  <p>I can be more concise so I do this:</p>
  
  <pre><code>scala&gt; g.foreach(println)
  1
  2
  3
  </code></pre>
  
  <p>All is good.</p>
  
  <p>Now when I do this:</p>
  
  <pre><code>scala&gt; g.foreach(println())
  &lt;console&gt;:9: error: type mismatch;
   found   : Unit
   required: Int =&gt; ?
                g.foreach(println())
  </code></pre>
  
  <p>Why do this fail? To me (a newbie), it seems like it is the equivalent of <code>g.foreach(println)</code>. Please can someone explain the error.</p>