You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose an extension to the 'Safe Navigation' ? operator. If the nested expression does not have a value the parent expression would evaluate to null without calling the method e.g:
Given we have a method signature int DoStuffAndGetValue(int arg)
The new syntax would be used like so var a = DoStuffAndGetValue(parent?.child.child?)
Such an operator would avoid the need of assigning a variable with parent?.child.child? or repeating the code with a ternary operator. It looks like a natural extension of the 'Safe Navigation' operator to me.
Regards,
Teodor
The text was updated successfully, but these errors were encountered:
tangelov
changed the title
Feature Request: 'Safe Invocation' operator
Feature Request: 'Safe Invocation' operator :Discussion :Proposal
Feb 6, 2019
tangelov
changed the title
Feature Request: 'Safe Invocation' operator :Discussion :Proposal
Feature Request: 'Safe Invocation' operator [Discussion] [Proposal]
Feb 6, 2019
Hi guys,
I propose an extension to the 'Safe Navigation'
?
operator. If the nested expression does not have a value the parent expression would evaluate tonull
without calling the method e.g:Given we have a method signature
int DoStuffAndGetValue(int arg)
The new syntax would be used like so
var a = DoStuffAndGetValue(parent?.child.child?)
Such an operator would avoid the need of assigning a variable with
parent?.child.child?
or repeating the code with a ternary operator. It looks like a natural extension of the 'Safe Navigation' operator to me.Regards,
Teodor
The text was updated successfully, but these errors were encountered: