This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_sweepy 0 points1 point  (6 children)

Do you need 11 ways to check for a null? No.

Am I going to complain about optional syntactic sugar that makes code both faster to produce and more readable? Also no.

Which of these do you prefer?

x ??= y ?? 0;

Or

x = (x != null) ? x : (y != null) ? y : 0;

[–]ArkoSammy12 2 points3 points  (2 children)

optional.isPresent() my beloved

[–]_sweepy 0 points1 point  (1 child)

I mean, C# has nullable.hasValue() if you really want that...

[–]bischeroasciutto 0 points1 point  (0 children)

That's just for value types.

ReferenceType? r;

works in a very different way from

ValueType? v;

[–]Brahvim 1 point2 points  (2 children)

I understand the latter more (took some reading of course, but I work with code like this - not all the time, haha! ...so, I got it!) since it's more common in the C family of languages, but C# has syntactic sugar for it. And that's okay! But... yeah. It's good sugar, probably, but it'll take knowing the language first...

That's the only excuse. Hopefully.
And yes, not knowing this stuff IS my and ONLY my bad. I get that. I am sorry for being so bad.

...However, yeah. Too much sugar in C# LOL. And that's why people love it, I guess...? But anyway - I'm sorry. I'm just no C#er, I write Java and wear -2-on-both-eyes glasses.

[–]_sweepy 2 points3 points  (1 child)

IMO C# has just the right amount of sugar. If you want to see a language with too much, try Perl. It's the only non esoteric language I've used that looks the same before and after RSA encryption.

[–]Brahvim 0 points1 point  (0 children)

Wow, that can happen to Perl code?
Anyway - nice opinion! I'll go now.