Re:Welcome to C# 9.0
by daeken on Wednesday May 20, 2020 @02:56PM
(#23250420)
Damn, this is fantastic. One big syntactical thing I should really put in a proposal for is null-conditional returns. Turning
Into
It fits perfectly with the existing null coalescing operators and such, while really cleaning up a lot of code.
[ Parent
| on HN ]
This look so very prone to cause bugs. Why would you even "return if not null"? I don't think I've been in this situation before. What I do see is if x is null then return something else, but this never
I think return is too important a keyword to make optional like that. However, I could totally get behind a shortening like
if(?foo){return null}
An interesting idea; it could be extended to other constructs - assignments, method calls... Also, imagine having something like this:
while (!return? foo) {
foo = get_foo();
}Oh please not. Hiding complexity is dangerous.
I'm confused. In the first code block, what value is returned if foo is equal to null?
If it returns null, what's the difference between:
>return foo;
and
>return? foo;
?
I am surprised that hasn't been done already.
Better not.
Re:Welcome to C# 9.0
by dullgiulio on Wednesday May 20, 2020 @03:47PM
(#23250943)
Perl# basically.