Which ever route is the easiest to read(usually it's the second one) is the one I pick. Less code is more.
I've worked with both a lot, and I find the second one is often better for my cognitive load. If you needif/else/elseif perhaps to many things are going on at once.
It depends on what kind of logic is needed, and which one reduces the amount of code and improves the readability.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Which ever route is the easiest to read(usually it's the second one) is the one I pick. Less code is more.
I've worked with both a lot, and I find the second one is often better for my cognitive load. If you need
if/else/elseif
perhaps to many things are going on at once.It depends on what kind of logic is needed, and which one reduces the amount of code and improves the readability.