Skip to content

Variables and Data Types

Devlish variables hold numbers, strings, booleans, null, records, or lists. Variables are created by assignment and do not require type annotations.

# Numbers (integers and decimals)
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 null

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.

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

Create ordered collections with list of.

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

Use field of record syntax to read a field value.

invoice_amount equals amount of invoice
project_name equals name of project

Nested access chains naturally:

city equals 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:

invoice_keys equals keys of invoice
invoice_values equals values of invoice
invoice_entries equals 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:

value_type equals type_of invoice
# Returns "record", "list", "number", "text", "boolean", or "null"