Boolean

Boolean is a logical data type which can either be true or false.

Operators

Logical operators

OperatorDescriptionExample
andConjunctiona == b
orDisjunctiona != b
!Negation!a
notNegation, long formnot(a)

Comparison operators

OperatorDescriptionExample
==Equalitya == b
!=Inequalitya != b

Ternary operator

It's possible to write a short in-line statement using ternary operator, if then else.

product.price > 100 ? 'premium' : 'value'; // if price is greater than 100 "premium" otherwise "value"

Functions

bool

Accepts one argument, tries to convert variable to boolean, throws an error on failure

bool('true'); // true
bool('false'); // false