Fork me on GitHub

Graceless Failures

Tips, tricks, missteps, and minor revelations on the path to Scala wisdom.

NumberFormatException

scala> "true".toBoolean
res1: Boolean = true

That’s pretty cool. Does it work for “false” too?

scala> "false".toBoolean
res1: Boolean = false

Yeah! Awesome! How does it handle other values, I wonder?

scala> "1".toBoolean
java.lang.NumberFormatException: For input string: "1"

… Err, what?