Optimized replace operator #8200
Unanswered
dmitriyse
asked this question in
Language Ideas
Replies: 2 comments
-
Coalescing other values is much less common than nulls. Moreover, comparing with null is well defined for reference types and nullable types, but for other values it may not be. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
Current State
C# already has a ternary operator, switch expression, and null-coalescing (??) operators.
However, these constructs don't cover the following widespread use case well.
Ternary expression syntax (already works):
switch expression syntax (already works):
null-coalescing (??) operator, works only for nullability checks:
Proposal:
Optimized syntax (proposal):
Or in general (proposal):
Alternative:
Beta Was this translation helpful? Give feedback.
All reactions