title: When are braces optional in Java 8 lambda syntax?
body: <p>I realise that the Java 8 lambda implementation is subject to change, but in lambda build b39, I've found that braces can only be omitted when the lambda expression returns a non-void type.  For example, this compiles:</p>
  
  <pre><code>public class Collections8 {
          public static void main(String[] args) {
                  Iterable&lt;String&gt; names = Arrays.asList("Alice", "Bob", "Charlie");
                  names.filter(e -&gt; e.length() &gt; 4).forEach(e -&gt; { System.out.println(e); });
          }
  }
  </code></pre>
  
  <p>But removing the braces like this:</p>
  
  <pre><code>names.filter(e -&gt; e.length() &gt; 4).forEach(e -&gt; System.out.println(e));
  </code></pre>
  
  <p>gives the error</p>
  
  <pre><code>Collections8.java:6: error: method forEach in interface Iterable&lt;T&gt; cannot be applied to given types;
          names.filter(e -&gt; e.length() &gt; 4).forEach(e -&gt; System.out.println(e));
                                           ^
    required: Block&lt;? super String&gt;
    found: lambda
    reason: incompatible return type void in lambda expression
    where T is a type-variable:
      T extends Object declared in interface Iterable
  </code></pre>
  
  <p>Can anyone explain what's going on here?</p>