Go TutorialLesson 7Free preview
Go Constants
This lesson is part of Go · All levels
Summary
This lesson discusses the Go constant, a fixed value that cannot be changed after being declared with the keyword const. The constants in Go are inherently untyped so flexible that they are used in expressions of various types. Go also provides iota as an automatic numbering in a group constant.
Key points
- A constant is declared with const and its value cannot be changed
- Untyped constants adjust type when used in an expression
- Iota is an automatic counter for a constant in a block
- The constant must be filled with a compilation value, not a runtime function result.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.