622
know the features of your language
(lemmy.world)
Post funny things about programming here! (Or just rant about your favourite programming language.)
If condition then this else that vs this ?? that
Which option do you think requires less time for a person to identify and understand?
Sure if it's just your own code do whatever comes natural to you but there's a reason we don't use these kind of logical operators in day to day speech is my point.
Ive been a backend dev for 2 years now and I've never come across the ?? operator and every time I come across a ternary operator I have to Google in what order comes what.
Not saying it doesn't make the code more concise and less "noisy" but sometimes a simple if else statement just makes the code easier to mantain
It’s easier to mess up
return a != null ? a : b
than it isreturn a ?? b
, and operators work from left to right.