Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scala> import scala.util.control.Exception.allCatch
- import scala.util.control.Exception.allCatch
- scala> val x: Option[Int] = allCatch.opt { "123".toInt }
- x: Option[Int] = Some(123)
- scala> x
- res0: Option[Int] = Some(123)
- scala> :type x
- Option[Int]
- scala> Console println x
- Some(123)
- scala> x
- res2: Option[Int] = Some(123)
- scala> val a: Int = x
- <console>:9: error: type mismatch;
- found : Option[Int]
- required: Int
- val a: Int = x
- ^
- scala>
Add Comment
Please, Sign In to add comment