exclusive_enums.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type dessert int | |
const ( | |
ICE_CREAM dessert = iota | |
CUP_CAKES | |
GUMMY_WORMS | |
) | |
type exclusive_dessert interface { | |
ignore_me() | |
} | |
func (d dessert) ignore_me() {} | |
// now use exclusive_dessert | |
func use_dessert(d exclusive_dessert) {} | |
// use_dessert(0) doesn't work! | |
// must use use_dessert(ICE_CREAM) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment