Otter
Snippets
Otter
Upstream Otter 1.0.1 Tested
Define & Instantiate Custom Type
Declare a strongly named domain record type with fields and instantiate it.
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 (D15)
- 3Zero external pack dependencies — paste directly into any .ot file
Source Code (2 files)
a ${TypeName} has
${field1}
${field2}
.
${variable} is a ${TypeName}
${field1} of ${variable} is ${value1}
${field2} of ${variable} is ${value2}
a Profile has
username
email
.
user is a Profile
username of user is "jeffrey"
email of user is "jeffrey@example.com"
say username of user "<" email of user ">"
if username of user is not "jeffrey"
fail with "profile username mismatch"
.
if email of user is not "jeffrey@example.com"
fail with "profile email mismatch"
.
Installation & Usage
otter snippet inspect data-custom-type
Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.