🐹 Go (Golang)
Beginner
What is a type declaration in Go?
Answer
A type declaration creates a new named type based on an existing type: type Celsius float64. The new type has the same underlying representation but is a distinct type — you cannot accidentally assign a Fahrenheit to a Celsius without an explicit conversion, preventing unit confusion bugs. You can attach methods to named types: func (c Celsius) ToFahrenheit() Fahrenheit { return Fahrenheit(c*9/5 + 32) }. This is how Go achieves type-safe domain modeling without heavyweight class hierarchies.