title: Convert Option to Either in Scala
body: <p>Suppose I need to convert <code>Option[Int]</code> to <code>Either[String, Int]</code> in Scala. I'd like to do it like this:</p>
  
  <pre><code>def foo(ox: Option[Int]): Either[String, Int] =
    ox.fold(Left("No number")) {x =&gt; Right(x)}
  </code></pre>
  
  <p>Unfortunately the code above doesn't compile and I need to add type <code>Either[String, Int]</code> explicitly:</p>
  
  <pre><code>ox.fold(Left("No number"): Either[String, Int]) { x =&gt; Right(x) }
  </code></pre>
  
  <p>Is it possible to convert <code>Option</code> to <code>Either</code> this way without adding the type ?<br>
  How would you suggest convert <code>Option</code> to <code>Either</code> ?</p>