E0069
Error
sum of an array that is not [i64] or [f64]
Errorsum() adds the elements of an array of i64 or of f64.
Why
Only i64 and f64 elements have a sum of the same type. Sisu does not convert a u8 or a bool to a number by itself.
Broken
fn main() {
let flags = [true, false]
print(flags.sum())
}
What sisu says
error[E0069]: `sum` needs an `[i64]` or an `[f64]`, found `[bool]` --> E0069.sisu:3:17 | 3 | print(flags.sum()) | ^^^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0069
Fixed
fn main() {
let flags = [true, false]
let mut count = 0
for flag in flags {
if flag {
count += 1
}
}
print(count)
}
Sisu