Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.

src/components/string-switch.x

Switches on a String.

Design notes

A switch on a String selects its case by content. Each label the switch owns becomes its index, so the body stays an ordinary integer switch on a helper’s result. The helper returns the index of the first label equal to the selector under ordinary ==, or 0. Switches on the same type with the same labels share one helper.

Each definition precedes the definitions that call it: the compiler settles whether a linked copy reaches a compile-time operation when the copy binds.