title: Conditional Future in Scala
body: <p>Given these two futures, I need to run the first one only if a condition is true (see <code>if y&gt;2</code>). But I get an exception <code>Future.filter predicate is not satisfied</code>. What does this mean and how to fix the example?</p>
  
  <pre><code>object TestFutures extends App {
  
    val f1 = Future {
      1
    }
  
    val f2 = Future {
      2
    }
  
    val y = 1
  
    val x = for {
      x1 &lt;- f1 if y&gt;2
      x2 &lt;- f2
    }  yield x1 + x2
  
  
    Thread.sleep(5000)
    println(x)
  }
  </code></pre>