title: Returning a null in a .map() versus .flatMap() in Reactor
body: <p>The following piece of code works :</p>
  
  <pre><code>// emitting employees...
  .flatMap(employee -&gt; {
  
      boolean isAlive = employee.isAlive();
  
      return Mono.just(isAlive)
  
              .flatMap(myBoolean -&gt; {
                  if (myBoolean) {
                      return Mono.empty();
                  } 
                  else {
                      return Mono.just(employee);
                  }
              });
  
  })
  </code></pre>
  
  <p>But I was wondering why I can't use a <code>.map</code> upon processing <code>myBoolean</code> (NullPointerException when it returns the null)</p>
  
  <pre><code>            .map(myBoolean -&gt; {
                  if (myBoolean) {
                      return null;
                  } 
                  else {
                      return employee;
                  }
              });
  </code></pre>
  
  <p>I believe I lack some understanding about the <code>map</code> versus <code>flatMap</code> </p>
  
  <p>In Java 8 streams I understand the difference between <code>map</code> and <code>flatMap</code> (for each item received, <code>map</code> emits 1, <code>flatMap</code> emits N)</p>
  
  <p>But in Reactor I'm a bit confused. I thought that both <code>map</code> and <code>flatMap</code> emit 1 item for each element received, the difference would be that the <code>map</code> emits it as a <code>Mono</code> while <code>flatMap</code> doesn't. To emit N items, I would use <code>flatMapMany</code>.</p>
  
  <p>Thanks in advance for your explanations !</p>