It's not even preference. Thing you suggested is not readable and there is nor practical reason to do it.
This debate is not new, and almost all developers have come to agreement that sparing couple of lines and sacrificing readability for it is not acceptable.
The good code is code that doesn't need explanation, when you read it you know what it does. When you see ternary operator you can guess, but with if else it's just so simple. Imagine junior coming to firm to learn from your code if else just makes all sense in the world.
I guess we'll have to agree to disagree. Again, I believe in the opposite of what you have said. To me, it is more much more readable.
The purpose is not to simply shorten code. The purpose is learn alternatives to the if statement.
The reason why it is important to learn alternatives to an if statement is because I am trying to promote functional programming and if/else are imperative statements.
So, because if/else is imperative, it is therefore anti-functional. So if you want to start coding in a functional way, you will need to learn alternatives to the coding styles you might be comfortable with.
Learning multiple ways to solve the same problems makes you a better programmer.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.