Re:Compile-time safety for enumerations in Go
by hamdouni on Saturday September 30, 2023 @06:09AM
(#37714077)
It's the game of the mouse and the cat :-D
We can change the package color like this :
[ Parent
| on HN ]
Re:Compile-time safety for enumerations in Go
by kiitos on Sunday October 01, 2023 @10:37PM
(#37733330)
func fn(c color.Color) {
switch c {
case color.Red, color.Green, color.Blue:
log.Printf("c=%#+v -- OK", c)
default:
log.Printf("c=%#+v -- should not be possible", c)
}
}
func main() {
var c color.Color
fn(c)
}
Output: c=<nil> -- should not be possible
:shrug: