Go Enumerations

From NovaOrdis Knowledge Base
Revision as of 22:35, 10 January 2024 by Ovidiu (talk | contribs) (Created page with "=Internal= * Go Language =Overview= Go does not have formal enums, but the language allows for sets of related, yet distinct constants. They represent a property that has several distinct possible values, like the days of the weeks or the months of the year. They are declared using the pre-declared constant <code>iota</code>: <syntaxhighlight lang='go'> type DayOfTheWeek int const ( MON D...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

Go does not have formal enums, but the language allows for sets of related, yet distinct constants. They represent a property that has several distinct possible 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
)