Shadowing in Scala's for-comprehensions is a nice feature. It has the feel of mutability, but safer, and shadowing's almost always what you want. for { x <- Try(doSomething) x <- mightFail(x) x <- returnTry(x) } yield x Unfortunately it only works with flatMaps, not maps.
-
-
A properly typed program would make more sense for this, surely
-
Or even using >>= in this instance: Try(something) >>= someOperation >>= andAnotherOne...
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.