Usability Operator (similar syntax to null check operator) #8533
Replies: 4 comments 21 replies
-
Not sure about the syntax, but I like the idea of the operator. Maybe just prepend an extra nonNullButNotChainableObject??.MethodCall(); // Usability Check operator
object obj = nonNullButNotChainableObject ??? defaultValueObject; // Usability coalesce operator |
Beta Was this translation helpful? Give feedback.
-
I don't understand what it does. Presumably it's syntactic sugar for some other concept; could you update your post showing how your proposal compares to pre-existing solutions? |
Beta Was this translation helpful? Give feedback.
-
What's the use case?
I would need to see examples of where this would be desirable in order to determine if this would be welcome or not. Specifically, I would need to strongly believe this is:
Could you expand upon the use case with real world examples? |
Beta Was this translation helpful? Give feedback.
-
Doesn't this generalize to monadic operations? Since we're getting tagged unions I'd rather just go all the way. |
Beta Was this translation helpful? Give feedback.
-
We had some in depth discussion on operators back in July on #2020
I was requested to create a separate discussion for the Usability Check operator idea.
Here's the guts:
Having a custom-definable usability check operator would be nice and beneficial, where we can define a custom method eval to see if a chained expression should terminate or continue. As a general language feature, would be a welcome addition, without impacting any existing operators (i.e. the null check operator remains completely untouched).
Proposed syntax:
??.
,!?.
, or similareg.
and optionally
Beta Was this translation helpful? Give feedback.
All reactions