karelpeeters
09/25/2018, 7:17 AM3, else
is just else
right?robin
09/25/2018, 7:33 AMKonstantin Petrukhnov
09/25/2018, 9:08 AMrobin
09/25/2018, 9:15 AMwhen (it) {
1 ->
2 ->
3 ->
4 ->
// case `1` is same as else-branch
else ->
}
And suddenly you're on your own to figure out if someone just forgot to delete the comment, or someone mistakenly added the 1-branch he thought was missing because he didn't read the statement to the end, or whatever. Documenting intent in a way that the compiler or at least the linter can help you with is always superior to comments, imo.Daniele Segato
09/25/2018, 9:54 AM<condition>,else
is mehkarelpeeters
09/25/2018, 9:56 AMDaniele Segato
09/25/2018, 9:56 AMkarelpeeters
09/25/2018, 9:57 AM3, else
with else
.Daniele Segato
09/25/2018, 9:58 AMwhen(t) {
1 -> "A"
2 -> "B"
// 3,
else -> "C"
}
like this?
this sucks honestly I prefer
when {
t == 1 -> "A"
t == 2 -> "B"
t == 3,
else -> "C"
}
at this pointadam-mcneilly
09/25/2018, 2:56 PMelse
. The opinionated part of this is: If 3 and "everything else" do the same thing, you don't have any reason to specify 3 as its own case, do you?robin
09/25/2018, 3:05 PMadam-mcneilly
09/25/2018, 3:29 PMrobin
09/25/2018, 3:37 PMadam-mcneilly
09/25/2018, 3:40 PMDaniele Segato
09/25/2018, 5:04 PMilya.gorbunov
09/25/2018, 6:02 PM