await? #8627
await?
#8627
-
Sometimes we want to await an object if it's not null, but awaiting a null object will give a NRE. So we either:
Both options are just more verbose/boilerplate than necessary. Example:
Or
These could be simplified to just:
The single question mark is already known as the null forgiving operator, so it would be clear what it's trying to achieve. The compiler can easily rewrite it to just perform the if statement for us, so it's syntactic sugar. |
Beta Was this translation helpful? Give feedback.
Answered by
timcassell
Nov 19, 2024
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
333fred
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#35