Language Feature? #2348
Replies: 4 comments
-
You could just do: Items.TryGetValue(RedirectUriKey, out var value);
return value; Ignoring the return value. The |
Beta Was this translation helpful? Give feedback.
-
True, and this is generally what I do (the sample above is actually from an MS AuthenticationProperties class related to their claims authentication abstraction). I don't suppose it would save much in that context, unless there's some sort of return register optimization to be had, which could probably be performed during compile-time optimization (if there was an optimization to be had here anyway) without the syntax sugar mentioned above. |
Beta Was this translation helpful? Give feedback.
-
Also, thanks for the pointers @YairHalberstadt |
Beta Was this translation helpful? Give feedback.
-
Normally I do return Items.TryGetValue(RedirectUriKey, out var value) ? value : null; I don't like your syntax. It hide the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@TheXenocide commented on Thu Mar 14 2019
I'm not sure what I would call this particular type of syntax sugar, but as I was reading through some source recently I wondered if there wasn't a readable way to simplify the following commonly occurring pattern? (Note: this is from some older sample source; I updated it here to use
out string value
already, where it was previously usingstring value;
on the preceding line)Surely it's not the most important feature request, but I figured it wouldn't hurt to ask. Maybe something like
Allowing
return
to be used in place ofout
orref
(possibly even optimizing around allocation behavior? I'm not sure of the internals involved here). I honestly haven't thought super deeply about this so feel free to shoot it down, but it was a thought I figured I'd share.@YairHalberstadt commented on Thu Mar 14 2019
This looks like it would be more appropriate for the csharplang repo, where requests for language changes are taken.
Also, if you're not sure of a suitable syntax, you might want to discuss your ideas on www.gitter.im/dotnet/csharplang first.
Beta Was this translation helpful? Give feedback.
All reactions