3 ms·
But in Go, case-values must be constants, right? This would make the trick from the referenced source code impossible, I think. (Whether or not that is a good o
by krylon 7y ago
But in Go, case-values must be constants, right? This would make the trick from the referenced source code impossible, I think. (Whether or not that is a good or a bad thing is a question I am deliberately ignoring.)
- lsaferite 7y agoNot true. Go uses logic expressions in the case statements all the time. And as pointed out above, a switch defaults to checking against true. https://tour.golang.org/flowcontrol/11 https://tour.golang.org/flowcontrol/11