title: How can I do 'if..else' inside a for-comprehension?
body: <p>I am asking a very basic question which confused me recently. 
  I want to write a Scala For expression to do something like the following:</p>
  
  <pre><code>for (i &lt;- expr1) {
    if (i.method) {
      for (j &lt;- i) {
        if (j.method) {
          doSomething()
        } else {
          doSomethingElseA()
        }
      }
    } else {
      doSomethingElseB()
    }
  }
  </code></pre>
  
  <p>The problem is that, in the multiple generators For expression, I don't know where can I put each for expression body.</p>
  
  <pre><code>for {i &lt;- expr1
    if(i.method) // where can I write the else logic ?
    j &lt;- i 
    if (j.method)
  } doSomething()
  </code></pre>
  
  <p>How can I rewrite the code in Scala Style?</p>