! operator for Nullable<T>.Value #4647
Unanswered
jods4
asked this question in
Language Ideas
Replies: 1 comment 6 replies
-
IMO there are two issues with this proposal as is:
The first one probably bothers me more, although if people are already applying |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to pick up #1865 where it was left off.
Nullable reference types and value types are similar on the surface but very different internally.
#1865 asked what features of NRT could be ported to NVT.
I understand that the LDM ruled off the idea of automatically unwrapping a
Nullable<T>
toT
based on dataflow analysis. That's sad but understandable.In #1865 several people were supportive of introducting
x!
for value types as well, as syntax sugar forx.Value
.I would really like if that could happen:
x!
is just sugar forx.Value
ifx
isNullable<T>
.Value
is long, ugly, unrelated to the meaning of the code and readability suffers. Usability of nullables has greatly improved thanks to pattern matching, this is one of the last commonly used painful nullable syntax.price!
was not working to grab the value of nullabledecimal? price
.Beta Was this translation helpful? Give feedback.
All reactions