Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.toBoolean

toBoolean() -> boolean

Description

Convert to Boolean type. Surrounding whitespace is ignored.

The following values are false: '', 'false', 'null', and '0'.

All other values are true.

'1'.toBoolean()  //= true
'0'.toBoolean()  //= false

' true'.toBoolean()   //= true
' false'.toBoolean()  //= false

See Also