Skip to content

Variables and Data Types

Variables let a program keep values and refer to them later by name. A value might be a number, a piece of text, a true/false answer, a list, or a record containing named fields. For example, an invoice can be a record whose amount and status fields are read separately.

This page explains how to create those values, read their contents, and update fields. Read Syntax Basics first for the meaning of equals and multi-word names. Expression snippets show the value being described; use them after equals, Print, or Respond with in a program.

# Numbers (integers and floating-point values)
count equals 42
rate equals 0.15
# Strings (double-quoted)
name equals "Solar Project Alpha"
# Booleans
is_active equals true
has_errors equals false
# Null
legacy_field equals nil

Write multi-word names naturally. Devlish normalizes them to snake_case.

contract value equals 500000
# Internally stored as contract_value
total exposure equals contract_value plus deductible

For extracted variables, use explicit snake_case in save as:

Find liability cap and save as liability_cap

Create structured data with named fields using record with.

record with 1200 as amount and "pending" as status
record with "Solar Farm" as name and 5000000 as value and true as active

Create ordered collections with list of.

list of "approved", "pending", and "rejected"
list of 85, 92, 78, and 95

Use field of record syntax to read a field value.

amount of invoice
name of project

Nested access chains naturally:

city of address of customer

Missing fields return nil rather than causing an error.

Use Set to mutate a field in place.

Set amount of invoice to 1300
Set status of project to "complete"

Nested updates create intermediate records if they do not exist:

Set city of address of customer to "Austin"

Extract structure from records:

keys of invoice
values of invoice
entries of invoice

Check that a record has expected fields or matches a type shape:

Require invoice has fields amount, customer
invoice_shape equals record with "number" as amount and "text" as customer
Require invoice matches shape invoice_shape

Shape values use type names: text, number, boolean, list, record, any.

Inspect the type of any value at runtime:

type of invoice
# Returns "record", "list", "number", "text", "boolean", or "null"