-
Notifications
You must be signed in to change notification settings - Fork 217
Closed
Labels
nnbdNNBD related issuesNNBD related issues
Description
It is frequently more readable to give a boolean expression a name for self-documentation. For example:
final bool isSingleElement = fields == null;
if (!isSingleElement) {
fields.forEach(...);
}
However, this does not promote fields
to non-null inside the if
block. A workaround is to remove the variable:
if (fields != null) {
fields.forEach(...);
}
However, this makes the code less readable, because non-nullness of fields
does not immediately imply that we're dealing with a "single line" mode of something.
Can the nullability inference be enhanced to infer using local booleans?
nturgut, mateusfccp, slightfoot, gustav3d and munificent
Metadata
Metadata
Assignees
Labels
nnbdNNBD related issuesNNBD related issues