essenceDocumentation
essenceDocs
on this pageAt a glance
Coming from JavaScript?

Boolean

type

The methods on true and false: logic, comparison and printing.

The two truth values, true and false, and the logic that combines them.

Taught on: Method calls and Conditions.

At a glance

Declared
namespace Boolean for Boolean

Equality, ordering and printing

is

on Boolean

is(_ other: Boolean) -> Boolean

Answers whether the Boolean has the same truth value as another.

NameTypeDescription
_Booleanthe Boolean to compare against

true when both are equal.

Example
expect true::is(true)
expect true::is(false)::negate()

compare

on Boolean

compare(to other: Boolean) -> Ordering

Orders the Boolean against another one, with false before true.

NameTypeDescription
toBooleanthe Boolean to order against

Ordering#Less, Ordering#Equal or Ordering#Greater.

Example
expect false::compare(to true)::is(#Less)
expect true::compare(to true)::is(#Equal)

toString

on Boolean

toString() -> String

Answers the Boolean as a String: "true" or "false".

Example
expect true::toString()::is("true")
expect false::toString()::is("false")

isNot

on Boolean · provided by Equatable

isNot(_ other: Boolean) -> Boolean

Answers whether the values differ.

NameTypeDescription
_Booleanthe value to compare with

true when the values differ.

Example
expect "Ada"::isNot("Grace")
expect 3::isNot(3)::negate()

Logic

negate

on Boolean

negate() -> Boolean

Answers the opposite truth value: false for true, and true for false.

Example
expect true::negate()::is(false)
expect false::negate()

and

on Boolean

and(_ other: Boolean) -> Boolean

Answers the logical conjunction: true only when both Booleans are true.

Both sides are evaluated. A call reads its Argument before the Method runs, so a false receiver does not stop the other side. Where the other side is expensive, write define { as other if flag as false otherwise }.

NameTypeDescription
_Booleanthe other Boolean
Example
expect true::and(true)
expect true::and(false)::negate()

or

on Boolean

or(_ other: Boolean) -> Boolean

Answers the logical disjunction: true when either Boolean is true.

Both sides are evaluated, as they are for and. Where the other side is expensive, write define { as true if flag as other otherwise }.

NameTypeDescription
_Booleanthe other Boolean
Example
expect false::or(true)
expect false::or(false)::negate()

exclusiveOr

on Boolean

exclusiveOr(_ other: Boolean) -> Boolean

Answers the exclusive disjunction: true when exactly one Boolean is true.

NameTypeDescription
_Booleanthe other Boolean
Example
expect true::exclusiveOr(false)
expect true::exclusiveOr(true)::negate()

Comparing

isLessThan

on Boolean · provided by Comparable

isLessThan(_ other: Boolean) -> Boolean

Answers whether the value is strictly below another.

NameTypeDescription
_Booleanthe value to compare with

true when the value is below the given one.

Example
expect 3::isLessThan(5)
expect 5::isLessThan(5)::negate()

isLessThanOrEqualTo

on Boolean · provided by Comparable

isLessThanOrEqualTo(_ other: Boolean) -> Boolean

Answers whether the value is below another, or equal to it.

NameTypeDescription
_Booleanthe value to compare with

true when the value is below the given one or equal to it.

Example
expect 3::isLessThanOrEqualTo(5)
expect 5::isLessThanOrEqualTo(5)

isGreaterThan

on Boolean · provided by Comparable

isGreaterThan(_ other: Boolean) -> Boolean

Answers whether the value is strictly above another.

NameTypeDescription
_Booleanthe value to compare with

true when the value is above the given one.

Example
expect "pear"::isGreaterThan("apple")
expect "pear"::isGreaterThan("pear")::negate()

isGreaterThanOrEqualTo

on Boolean · provided by Comparable

isGreaterThanOrEqualTo(_ other: Boolean) -> Boolean

Answers whether the value is above another, or equal to it.

NameTypeDescription
_Booleanthe value to compare with

true when the value is above the given one or equal to it.

Example
expect 5::isGreaterThanOrEqualTo(3)
expect 5::isGreaterThanOrEqualTo(5)
esc