Give values a shape
Our workflow now has two facts to consider: an amount and whether the request is urgent. A record keeps related values together and gives each one a name.
pub type Request { pub amount: Int, pub urgent: Bool }
pub flow main(request: Request) -> Bool = request.urgent || request.amount > 100
falseRead a record at the boundary
Request has an integer amount and a boolean urgent. The input object mirrors those fields under the parameter name request. Read request.urgent as the urgent field of that value.
The expression request.urgent || request.amount > 100 needs review when either condition is true. Try a small urgent request and a large non-urgent one. The exercise asks you to include the boundary amount of 100 without losing urgency handling.
Make alternatives explicit
A record groups facts that exist together. A choice describes alternatives. Instead of returning arbitrary text, we can name the two possible decisions:
pub type Decision { Proceed, Review }
pub flow main(amount: Int) -> Decision = if amount > 100 { Review } else { Proceed }
"Proceed"Decision has the alternatives Proceed and Review. A caller can handle them with match. Adding a third alternative changes what callers must consider; a misspelled text string would not carry the same structure.
Use a record when a value needs several fields. Use a choice when a value is one of several forms. Both let the type describe something meaningful about the workflow, beyond the shape of a JSON object.
Exact rules: records, choices and visibility, pattern matching.