The switch statement in the loop-with-switch approach had two explicit cases and a default.
The three cases that exist are:
equal
less than
greater than
If we want to have two explicit cases and a default, then it would feel more symmetrical to have the less-than and greater-than cases be defined explicitly with the equal case being the default.
However, it's hard to argue that any of the three are actually a default here.
Instead I've changed it to have three explicit cases.
Since there is an explicit return if we fall out of the for loop, we don't technically need the default.
The switch statement in the loop-with-switch approach had two explicit cases and a default.
The three cases that exist are:
If we want to have two explicit cases and a default, then it would feel more symmetrical to have the less-than and greater-than cases be defined explicitly with the equal case being the default.
However, it's hard to argue that any of the three are actually a default here.
Instead I've changed it to have three explicit cases.
Since there is an explicit return if we fall out of the
for
loop, we don't technically need the default.Thoughts?