else handles the bad case of a T!, a T?, or a pattern that might not match. This value is
a plain type and the pattern always matches, so the else could never run.
Wrong#
fn main() {
let x = 1 else 2
print(x)
}Fixed#
fn main() {
let x = 1
print(x)
}Common causes#
- A function that used to return
T?orT!and now returns a plain value. elseused as a general "or" operator: useif/elsefor conditions.