LYR-SEM0004
a condition that is not a bool
The condition of an if, while, do … while or a guard has a type other than bool.
Explanation
A condition is a bool; nothing converts to one. A number is not true when it is non-zero, and an optional is not true when it holds a value.
Write the test out: n != 0, x != null, !s.isEmpty().
Wrong
fn main(): void {
let n = 3;
if (n) { let _ = n; }
}
Right
fn main(): void {
let n = 3;
if (n != 0) { let _ = n; }
}