Otter
Snippets
Otter
Upstream Otter 1.0.1 Tested
Dynamic Object Literal (has block)
Construct an ad-hoc key-value data structure with named properties.
Architecture & Runtime Preview
Otter 1.0.1Zero-dependency Otter 1.0.1 snippet (Data & Records). Copy the parameterized template or run the self-contained example.
- 1Category: Data & Records
- 2Attribution: Otter Core Language Spec (D40)
- 3Zero external pack dependencies — paste directly into any .ot file
Source Code (2 files)
${variable} has
${property} is ${value}
.
serverConfig has
host is "127.0.0.1"
port is 8080
active is true
.
say "Listening on" host of serverConfig ":" port of serverConfig
if host of serverConfig is not "127.0.0.1"
fail with "serverConfig host mismatch"
.
if port of serverConfig is not 8080
fail with "serverConfig port mismatch"
.
if active of serverConfig is not true
fail with "serverConfig active flag mismatch"
.
Installation & Usage
otter snippet inspect data-object-thing
Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.