You are viewing a single comment's thread. Return to all comments →
It's not dumb at all. return condition makes sense when the condition is simple. However,
return condition
return year % 4 == 0 and (year % 400 == 0 or year % 100 != 0)
requires more mental work to understand than the if-else solution. Readability is very important.
Also this is not a good DRY example as it is actually easier to make changes to the if-else solution.
Seems like cookies are disabled on this browser, please enable them to open this website
Write a function
You are viewing a single comment's thread. Return to all comments →
It's not dumb at all.
return condition
makes sense when the condition is simple. However,requires more mental work to understand than the if-else solution. Readability is very important.
Also this is not a good DRY example as it is actually easier to make changes to the if-else solution.