title: What's the difference between => , ()=>, and Unit=>
body: <p>I'm trying to represent a function that takes no arguments and returns no value (I'm simulating the setTimeout function in JavaScript, if you must know.)</p>
  
  <pre><code>case class Scheduled(time : Int, callback :  =&gt; Unit)
  </code></pre>
  
  <p>doesn't compile, saying " `val' parameters may not be call-by-name"</p>
  
  <pre><code>case class Scheduled(time : Int, callback :  () =&gt; Unit)  
  </code></pre>
  
  <p>compiles, but has to be invoked strangely, instead of</p>
  
  <pre><code>Scheduled(40, { println("x") } )
  </code></pre>
  
  <p>I have to do this</p>
  
  <pre><code>Scheduled(40, { () =&gt; println("x") } )      
  </code></pre>
  
  <p>What also works is</p>
  
  <pre><code>class Scheduled(time : Int, callback :  Unit =&gt; Unit)
  </code></pre>
  
  <p>but is invoked in an even-less-sensible way</p>
  
  <pre><code> Scheduled(40, { x : Unit =&gt; println("x") } )
  </code></pre>
  
  <p>(What would a variable of type Unit be?)  What I <em>want</em> of course is a constructor that can be invoke the way I would invoke it if it were an ordinary function:</p>
  
  <pre><code> Scheduled(40, println("x") )
  </code></pre>
  
  <p>Give baby his bottle!</p>