Logic functions
Every function in this family, with its signature and examples. Each example runs as a test of the language. See Language basics for how calls, types, and operators work.
if
Returns the first value if the condition is true; otherwise, returns the second value.
if(condition: boolean, then: any, else: any) → any
if(true, 1, 2)gives1if(false, 1, 2)gives2true ? "Complete" : "Incomplete"gives"Complete"
ifs
Returns the value of the first true condition, or the last value when none is true, in place of nested if() calls.
ifs(condition: boolean, value: any, condition2: boolean, value2: any, …, else: any) → any
ifs(true, 1, true, 2, 3)gives1ifs(false, 1, true, 2, 3)gives2ifs(false, 1, false, 2, 3)gives3
empty
Returns true if the value is empty; 0, "", and [] are empty.
empty(value: any) → boolean
Also callable as receiver.empty(…), with the receiver as the first argument.
empty(0)givestrueempty("")givestrueempty([])givestrue"Notion".empty()givesfalse
equal
Returns true if both values are equal and false otherwise, the same as ==.
equal(a: any, b: any) → boolean
Also callable as receiver.equal(…), with the receiver as the first argument.
equal(1, 1)givestrue"a" == "b"givesfalse"1" == 1givesfalse[1, 2] == [2, 1]givesfalse
unequal
Returns false if both values are equal and true otherwise, the same as !=.
unequal(a: any, b: any) → boolean
Also callable as receiver.unequal(…), with the receiver as the first argument.
unequal(1, 2)givestrue"a" != "a"givesfalse
and
Returns the logical AND of its two arguments.
and(a: boolean, b: boolean) → boolean
Also callable as receiver.and(…), with the receiver as the first argument.
and(true, false)givesfalsetrue && truegivestruetrue and falsegivesfalse
or
Returns the logical OR of its two arguments.
or(a: boolean, b: boolean) → boolean
Also callable as receiver.or(…), with the receiver as the first argument.
or(true, false)givestruefalse || falsegivesfalsefalse or truegivestrue
not
Returns the logical NOT of its argument.
not(value: boolean) → boolean
Also callable as receiver.not(…), with the receiver as the first argument.
not(true)givesfalse!falsegivestruenot truegivesfalse
let
Binds a name to a value for the body expression, so a value computed once can be used several times.
let(name, value: any, body: any) → any
let(x, 10, x * 2)gives20let(word, "go", word + word)gives"gogo"
lets
Binds several names in order for the body expression; each value can use the names bound before it.
lets(name, value: any, name2, value2: any, …, body: any) → any
lets(a, 1, b, a + 1, a + b)gives3