David Crawshaw David Crawshaw - 1 year ago 121
Scala Question

Scala: Elegant conversion of a string into a boolean

In Java you can write

. However in Scala,
is hidden by
which lacks this function. It's easy enough to switch to using the original Java version of a boolean, but that just doesn't seem right.

So what is the one-line, canonical solution in Scala for extracting
from a string?

Answer Source

Ah, I am silly. The answer is myString.toBoolean.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download