title: Scala Returning a void function with 0 parameters, ugly syntax?
body: <p>Given a method defined as follows</p>
  
  <pre><code> def descendEach(times:Int)(f:()=&gt;Unit) {
        for (i &lt;- 1 to times) {
            // other code
            f()
        }
     }
  </code></pre>
  
  <p>when I use this method I want to be able to write</p>
  
  <pre><code> gd.descendEach(20){
      println(gd.cost)
   }
  </code></pre>
  
  <p>but the scala compiler only lets me get away with</p>
  
  <pre><code>  gd.descendEach(20){ () =&gt; 
      println(gd.cost)
   }
  </code></pre>
  
  <p>which is kind of ugly. Am I missing something here? Is it possible to write it in the first way I presented?</p>