October 2015
Beginner to intermediate
400 pages
14h 44m
English
A value of type bool, or boolean, has only two possible values,
true and false.
The conditions in if and for statements are booleans, and comparison
operators like == and < produce a boolean result. The unary operator ! is
logical negation, so !true is false, or, one might say,
(!true==false)==true, although as a matter of style, we always
simplify redundant boolean expressions like x==true to x.
Boolean values can be combined with the && (AND) and || (OR)
operators, which have short-circuit behavior: if the answer is
already determined by the value of the left operand, the right operand
is not evaluated, making it safe to write expressions like this:
s != "" && s[0] == 'x'
where s[0] would panic if applied to an empty ...
Read now
Unlock full access