Curriculum Foundations Conditionals & switch exercise 4 · mcq
Conditionals & switch
Go's switch has two shapes the previous exercise didn't show.
Pick the idiomatic Go translation of this TypeScript.
TypeScript reference
About this theme
if/else looks familiar — no parentheses, braces required. The one new shape is the short-statement-if: if err := work(); err != nil { ... }. It scopes a temporary to the condition; you'll see this everywhere in Go. switch exists and doesn't fall through by default — closer to TypeScript's switch with implicit break than to C's.