this post was submitted on 07 Oct 2025
171 points (91.3% liked)
Programmer Humor
26891 readers
458 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
When you're an old-head who recognizes the old style it is easy to read the old style.
When you're a new-head who recognizes the new style it is easy to read the new style.
When you've never seen C# before, they're both gibberish.
When you've got experience with both, it can get a little confusing but you'll catch on without too much difficulty.
But its fucking wild to think the left side is more readable than the right side, simply because it is more verbose.
Eh, I haven't touched C# since 2001. I agree that the more verbose style is more explicit, and so more readable. That said, I can figure most of the new style out from context.
=>
is clearly a closure declaration operator, similar to JavaScript.x ??= y
is shorthand for "assign y to x if x is not set, and return x" which is kind of nice.There must also be some shorthand going on for getter properties being the same as methods w/o an arglist (or even a
()
).The only part that has me stumped is the unary question-mark operator:
private static Singleton? _instance = null;
I can think of a half-dozen things that could be, but I cannot decide what it's doing that the original question-mark-free version isn't.The only thing that's not obvious to me is that
??=
doesn't seem to invokenew Singleton()
if it's already defined, essentially short-circuiting. Otherwise I would have to look up the semantics of it if I were worried about that constructor having side effects or doing something heavy.