Go Enumerations: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
=External= | |||
* https://blog.boot.dev/golang/golang-enum | |||
=Internal= | =Internal= | ||
* [[Go_Language#Enumerations|Go Language]] | * [[Go_Language#Enumerations|Go Language]] |
Revision as of 22:38, 10 January 2024
External
Internal
Overview
Go does not have formal enums, but the language allows for sets of related, yet distinct int
constants. They represent a property that has several distinct possible int
values, like the days of the weeks or the months of the year. They are declared using the pre-declared constant iota
:
type DayOfTheWeek int
const (
MON DayOfTheWeek = iota
TUE
WED
THU
FRI
SAT
SUN
)