This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Functions - lang.boolean

fromString

Converts a string to a boolean.

fromString

(string s)

returns boolean | error

Converts a string to a boolean. Returns the boolean of which s is a string representation. The accepted representations are true, false (in any combination of lower- and upper-case), and also 1 for true and 0 for false. This is the inverse of value:toString applied to a boolean.

Parameters

  • s string
  • string representing a boolean value

  • Return Type

    (boolean | error)
  • boolean that s represents, or an error if there is no such boolean