title: Anonymous class replaced with lambda expressions
body: <p>I have sample code which uses Java 8 new <a href="http://download.java.net/jdk8/docs/api/java/util/stream/package-summary.html">stream functionality</a> (get a range of int values 1 .. 20, skip the first 9, then take remaining 10, each int value: reduce by one and multiply by 2).
  </p>
  
  <pre><code>System.out.println(Arrays.toString(
      IntStream.rangeClosed(1, 20).skip(9).limit(10).map((new IntUnaryOperator() {
          @Override
          public int applyAsInt(int operand) {
              return operand - 1;
          }
      }).andThen(new IntUnaryOperator() {
          @Override
          public int applyAsInt(int operand) {
              return operand * 2;
          }
      })).toArray()));
  </code></pre>
  
  <p>The output is as follows:</p>
  
  <pre><code>[18, 20, 22, 24, 26, 28, 30, 32, 34, 36]
  </code></pre>
  
  <p>Now I want to replace anonymous classes with <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html">Lambda expressions</a>. The following conversion works fine (the second anonymous class replaced with <code>i -&gt; i * 2</code> lambda expression) and I get the same output:
  </p>
  
  <pre><code>System.out.println(Arrays.toString(
      IntStream.rangeClosed(1, 20).skip(9).limit(10).map((new IntUnaryOperator() {
          @Override
          public int applyAsInt(int operand) {
              return operand - 1;
          }
      }).andThen(i -&gt; i * 2)).toArray()));
  </code></pre>
  
  <p>However, when I replace the first anonymous class with lambda expression:
  </p>
  
  <pre><code>System.out.println(
      Arrays.toString(
          IntStream.rangeClosed(1, 20).skip(9).limit(10)
              .map((v -&gt; v - 1).andThen(i -&gt; i * 2)).toArray()));
  </code></pre>
  
  <p>I am not able to compile my code. The error says <code>Operator '-' cannot be applied to '&lt;lambda parameter&gt;', 'int'</code></p>
  
  <p><img src="https://i.stack.imgur.com/EtHsI.png" alt="Compilation error"></p>
  
  <p>Do you know how to combine two lambda expressions with <code>IntUnaryOperator.andThen</code>?</p>
  
  <p>I know I could use ... <code>.limit(10).map(v -&gt; v - 1).map(i -&gt; i * 2).toArray() ...</code> which works fine but I would like to find out how to use <code>IntUnaryOperator.andThen</code> with lambdas (if that possible).</p>