nfrankel
12/15/2019, 6:13 PMDaniel
12/15/2019, 7:44 PMif(..) {
doSomething()
} else if(...) {
doSomethingElse()
}
and you are good to go and will understand it even after you were away from the code for some timeDaniel
12/15/2019, 7:48 PMnfrankel
12/15/2019, 9:28 PMHi and a huge thanks for your blog!thanks 🙂
You can rewrite the code once there is a case in the future where the signatures of the “do” methods differif believe this is pretty clear if you don’t want to go the full way on the opposite, i would advise to start with the full map things, and only then revert one level back if the signatures start diverging
nfrankel
12/15/2019, 9:29 PMDaniel
12/15/2019, 9:48 PMnfrankel
12/15/2019, 10:08 PMIts really a fine line in programming!yep, i wouldn’t bet any part of my anatomy on it
thana
12/16/2019, 7:30 AMwhen(input) {
"A" -> 1
"B" -> 2
"C" -> 3
}
?
And taking that further, imagine a scenario where you'd be tempted to use a sealed class
or an enum
as map keys? Why give up on the exhaustiveness check?Alexander Romanov
12/16/2019, 3:10 PMwhen
is as expressive, so map doesn’t bring anything to the tablenfrankel
12/16/2019, 3:38 PM&&
it’s imho much harder to readAlexander Romanov
12/16/2019, 3:44 PMwhen (var1 to var2) {
"a" to "b" -> …
"a" to "c" -> …
}
Alexander Romanov
12/16/2019, 3:47 PMnfrankel
12/16/2019, 4:44 PMPair
i understand