title: Using multiple map functions vs. a block statement in a map in a java stream
body: <p>Say I have the following code</p>
  
  <pre><code>data.stream()
      .map(x -&gt; {
          Object a = maybeReturnsNull(x);
          return a == null ? defaultValue : a;
      })
  </code></pre>
  
  <p>I have some function that might be returning <code>null</code>, and I'm applying it to an element of the stream. I then want to make sure that any <code>null</code> results get changed to some default value instead. Is there any significant difference between using two maps as in the following example, as compared to using the previous example that defines a helper variable <code>a</code> and uses a code block in the lambda expression? </p>
  
  <pre><code>data.stream()
      .map(x -&gt; maybeReturnsNull(x))
      .map(x -&gt; x == null ? defaultValue : x)
  </code></pre>
  
  <p>Is there a standard on where or not to avoid using block statements with lambda functions? </p>