title: How to merge two types of for comprehension in Scala?
body: <p>I have seen for being used different ways in Scala, to take some value out of a wrapper like Option or on list or other collections. If I have to pull a <code>List[Int]</code> out of an <code>Option</code> and then iterate on it, can this be done in one for block?</p>
  
  <p>eg. </p>
  
  <pre><code>val l: Option[List[Int]] = Some(List(1,2,3,4)) 
  l: Option[List[Int]] = Some(List(1, 2, 3, 4))
   for{
    li &lt;- l       // li taken out from Option wrapper
    number &lt;- li  // numbers pulled from li
  } yield number*2 
  cmd7.scala:3: type mismatch;
   found   : List[Int]
   required: Option[?]
  number &lt;- li
         ^
  </code></pre>
  
  <p>If I understand correctly it wants each entry to be an <code>Option</code>. Is there some way to achieve this effect without two for loops?</p>