Curriculum Types & methods Structs exercise 2 · mcq
Structs
Construct a struct value. Pick the IDIOMATIC Go literal — named fields, not positional. Go allows BOTH forms, but positional literals are a known maintenance hazard: add a field in the middle of the struct declaration and every positional caller silently misalines. Named literals are the canon for anything with more than two fields.
TypeScript reference
About this theme
type Foo struct { ... }. A struct is a typed record — fields and their types, nothing else. No methods on the struct itself (those come next). Field access with .. Struct literals can be positional or named; named is the only sane choice for anything with more than two fields.