exercism / go

Exercism exercises in Go.
https://exercism.org/tracks/go
MIT License
951 stars 644 forks source link

Tweak code example in binary-search approach #2713

Closed kytrinyx closed 9 months ago

kytrinyx commented 9 months ago

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?