bool - pannous/warp GitHub Wiki

bool is its own type with two values, yes and no (true and false are the same values). A bool prints as yes or no and acts like the numbers 1 and 0:

yes + 1       // 2
no == 0       // yes
yes == 1      // yes
bool(0)       // no

Only the number 0 equals no. Empty values such as '', [], {} and ø are not equal to no, but they are falsy: an if or while treats them as no, see Truthiness. Arithmetic on ø stays an error: () + 1 is "cannot extract a numeric value from ø".

bool(x) gives the truthiness of any value: bool([]) is false and bool([0]) is true (planned for collections, card bool-of-collection).

as bool and bool(text) are conversions: they read the word, as "80" as int gives 80. The words no, false and 0 and the empty text are no, any other text is yes:

"no" as bool       // no
bool("0")          // no
"hello" as bool    // yes

A condition does not convert: if takes every non-empty text as yes, so if "0" {1} else {2} is 1.