3 ms·
As much as I want to emphasize that this is not the right way to think about programming in Go, I do want to point out that the example has a lot of extra cod
by Jabbles 13y ago
As much as I want to emphasize that this is not the right way to think about programming in Go, I do want to point out that the example has a lot of extra code that isn't needed. Indeed, it's not really possible to have a bug of the kind the author wrote if written properly:
http://play.golang.org/p/puZBEmOVaI http://play.golang.org/p/puZBEmOVaI
- DocSavage 13y agoThe explicit type switch also lets you streamline handling of uint8, uint16, etc (just return value) and panic or error if given a type you don't expect. But I find it unfortunate that type switches must have single type cases. For example, it's too bad this doesn't work: http://play.golang.org/p/a4j1I6Oug- http://play.golang.org/p/a4j1I6Oug- The OP's complaint would be minor if the compiler would auto-unroll the multi-type case clause.
- deleted 13y ago[deleted]