title: Generics with code block returning Unit
body: <p>I have the following code that is working and printing "foreach executed ":
  </p>
  
  <pre><code>val buf = ArrayBuffer[() =&gt; Unit]()
  def add(o: () =&gt; Unit) = buf += o
  add(() =&gt; print("executed "))
  print("foreach ")
  buf foreach (_())
  </code></pre>
  
  <p>I would like to simplify line 3, but it breaks at first line:
  </p>
  
  <pre><code>val buf = ArrayBuffer[=&gt; Unit]()
  def add(o: =&gt; Unit) = buf += o
  add { print("executed ") }
  print("foreach ")
  buf foreach (_)
  </code></pre>
  
  <p>Is there a way to do it?</p>