{switch 'odd', 'even'} prints one of its values and moves one step on, so the next time it runs it prints the next one, and after the last it starts over. Written inside a loop it gives alternating values per row - a class or a background colour for zebra stripes - without counting anything yourself.

The position is remembered for the whole request and is keyed on the tag's text as written. Two {switch} tags written exactly alike therefore share one rotation, even in different loops: the second loop goes on where the first one stopped. Write them differently (another value, or other spacing) to give each its own rotation. A nested pass - a {code} or {sandbox} evaluation - takes its rotation steps back when it returns.

The rotation does not follow the row number, so a {switch} inside an {if} only steps on the rows where it runs. When the colour must follow the row itself, use the loop's property: {even@items ? 'even' : 'odd'}.

Under the strict syntax check a {switch} with no values is an error.