Re:What's New in C# 14: Null-Conditional Assignments
by hahn-kev on Thursday September 18, 2025 @02:46AM
(#45286323)
Without it there's some silly inconsistency. For example I could call `person?.SetName(name)`, but if you wanted to refactor that into `person?.Name = name` you can't.
[ Parent
| on HN ]
Re:What's New in C# 14: Null-Conditional Assignments
by ffsm8 on Thursday September 18, 2025 @03:03AM
(#45286460)
That's a great point I didn't think about. From that perspective, it does make sense.
Maybe my feeling is just rooted in the fact I've never used a language which allowed ?. on assignment
Re:What's New in C# 14: Null-Conditional Assignments
by moomin on Thursday September 18, 2025 @03:27AM
(#45286623)
My take is that it’s pretty minor. Modern C# has across the board null checking and for the most part you’re not designing things where this even comes up. You are, however, correct, in that I have 100% seen the ?SetName thing used by devs who just wanted to make the null checker go away and didn’t actually think about what the correct behaviour was.