I'm not really sure why but lately, when reviewing code, I've preferred code where if/else-if (or if/elif) chains have an explicit else, even if it doesn't affect code behaviour.

E.g. in hypothetical #Python,

for item in collection:
if (first_condition):
item.modify_state()
elif (second_condition):
item.modify_state_differently()

I actually find it more readable when there's

else:
continue

in the loop too.

Is it just me? Or is it actually a thing?

Follow

@warrickball it depends on the day, some days I'm a simpleton and I prefer it simple, the shorter the better. Other days I have a desperate need to have everything explicit, otherwise I don't have any confidence

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.