Go switch

From NovaOrdis Knowledge Base
Revision as of 00:07, 13 August 2024 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

Same as for if, switch accepts an optional initialization statement.

The cases are evaluated top to bottom until a match is found. The expressions need not be constants or even integers.

It is idiomatic to write an if-else-if-else as a switch.

Tagless Switch