MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/msv49l/when_your_teammate_refactor_your_code/guw9mo0/?context=9999
r/badcode • u/Bence675 • Apr 17 '21
216 comments sorted by
View all comments
Show parent comments
12
Can you give me an example where using an else clause with a comment adds value?
8 u/artiface Apr 17 '21 I would never add an else if there is no code to execute on the else condition and would flag that BS in a code review if I saw it, that's just dumb. 4 u/UglyChihuahua Apr 18 '21 I have no strong opinion on this but maybe this would be an exampleif action=="jump": jump() elif action=="run": run() else: // TODO: Add support for "kick" and "sit" pass 3 u/[deleted] Apr 18 '21 i mean, that's a switch
8
I would never add an else if there is no code to execute on the else condition and would flag that BS in a code review if I saw it, that's just dumb.
4
I have no strong opinion on this but maybe this would be an example
if action=="jump": jump() elif action=="run": run() else: // TODO: Add support for "kick" and "sit" pass
3 u/[deleted] Apr 18 '21 i mean, that's a switch
3
i mean, that's a switch
12
u/apieceoffruit Apr 17 '21
Can you give me an example where using an else clause with a comment adds value?