Otter
Snippets
Otter
Upstream Otter 1.0.1 Tested
For Each Loop
Iterate over elements in a list using the idiomatic Otter loop syntax.
Architecture & Runtime Preview
Otter 1.0.1Zero-dependency Otter 1.0.1 snippet (Control Flow). Copy the parameterized template or run the self-contained example.
- 1Category: Control Flow
- 2Attribution: Otter Core Language Spec (D13, D36)
- 3Zero external pack dependencies — paste directly into any .ot file
Source Code (2 files)
for each ${item} in ${items}
say ${item}
.
items are
"Ruby"
"Otter"
"C#"
.
itemCount is 0
for each item in items
say "Language:" item
increase itemCount by 1
.
if itemCount is not 3
fail with "for-each count mismatch"
.
Installation & Usage
otter snippet inspect cf-for-each
Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.