Bool

Functions for interacting with JavaScript booleans. See: Boolean

compare

RESCRIPT
let compare: (bool, bool) => Ordering.t

Compares two booleans, returns an Ordering.t value.

Examples

RESCRIPT
Bool.compare(true, true) == Ordering.equal Bool.compare(false, false) == Ordering.equal Bool.compare(true, false) == Ordering.greater Bool.compare(false, true) == Ordering.less

equal

RESCRIPT
let equal: (bool, bool) => bool

Checks if two booleans are equal and have the same value.

Examples

RESCRIPT
Bool.equal(true, true) == true Bool.equal(false, false) == true Bool.equal(true, false) == false Bool.equal(false, true) == false

fromString

RESCRIPT
let fromString: string => option<bool>

Converts a string to a boolean.

Examples

RESCRIPT
Bool.fromString("true") == Some(true) Bool.fromString("false") == Some(false) Bool.fromString("notAValidBoolean") == None

fromStringExn

Deprecated

RESCRIPT
let fromStringExn: string => bool

Converts a string to a boolean. Beware, this function will throw an Invalid_argument exception if the string is not a valid boolean.

Examples

RESCRIPT
Bool.fromStringExn("true") == true Bool.fromStringExn("false") == false switch Bool.fromStringExn("notAValidBoolean") { | exception Invalid_argument(_) => assert(true) | _ => assert(false) }

fromStringOrThrow

RESCRIPT
let fromStringOrThrow: string => bool

Converts a string to a boolean. Throws an Invalid_argument exception if the string is not a valid boolean.

Examples

RESCRIPT
Bool.fromStringOrThrow("true") == true Bool.fromStringOrThrow("false") == false switch Bool.fromStringOrThrow("notAValidBoolean") { | exception Invalid_argument(_) => assert(true) | _ => assert(false) }

t

RESCRIPT
type t = bool

Type representing a boolean.

toString

RESCRIPT
let toString: bool => string

Converts a boolean to a string.

Examples

RESCRIPT
Bool.toString(true) == "true" Bool.toString(false) == "false"