4 ms·
I would like to postulate that having an else makes it easier to read. We think in if/else fuzzy scenarios, it's why it flows so well in code. If you were teach
by 100011_100001 6y ago
I would like to postulate that having an else makes it easier to read. We think in if/else fuzzy scenarios, it's why it flows so well in code. If you were teaching someone about traffic lights you would verbally explain something like this:
if (light == green) {
go()
} else {
stop()
}
Not this:
if (light != green) {
stop()
}
go()
...and we haven't handled what to do when the light is orange.
Edit: In total agreement about the the single return, which is why I ignored that part of your post.