News for hackers. Stuff that matters.
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:

There are no comments on this comment yet.