-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
General info
- Dart 2.19.6 (stable) (Tue Mar 28 13:41:04 2023 +0000) on "macos_arm64"
- on macos / Version 15.6.1 (Build 24G90)
- locale is en-US
- Chrome
val: autoDismiss ?? shouldDoSomething ? state.autoDismiss : false
According to the operators documentation, an if-null should be considered higher priority than a ternary operation. However, in our app we were seeing that if autoDismiss was set to true, we were still setting val to false. shouldDoSomething is false in this scenario.
I would have expected this to be read as if autoDismiss is null, then evaluate the ternary, but it seems to be evaluating instead as autoDismiss(true) AND shouldDoSomething(false), then evaluate the ternary or just ignoring the if-null portion.
Adding parentheses resolves the issue and evaluates the way that I would expect.
val: autoDismiss ?? (shouldDoSomething ? state.autoDismiss : false)
Is this expected behavior?
Metadata
Metadata
Assignees
Labels
No labels