Consider the following program, which in lines 6 and 7, gives a warning that "expression does not yield a value" for an if statement and the left-hand side of an assignment statement respectively, but does not warn for line 5, which is where the real problem is, that we are assigning the result of a void function to a variable.
main() {
for (var i = 0; i < 10; i++) {
for (var each in [1, 2, 3, 4, 5]) {
var newFoo = foo(i, each);
if (newFoo != null) {
newFoo[3] = 4;
}
}
}
}
void foo(x, y) => print("$x, $y");