Expressions
Last updated
Was this helpful?
Last updated
Was this helpful?
Expressions in Midio allow you to write small snippets of logic directly inside function inputs. They can be used anywhere a function input is editable and are a powerful way to perform computations or dynamically construct values inline.
Expressions support many of the constructs you'd expect from a general-purpose language:
Unary and binary operators: Use operators like +
, -
, *
, /
, !
, and more to perform arithmetic and logical operations.
Ternary operator: Use the condition ? valueIfTrue : valueIfFalse
form to choose between values based on a condition.
Literals: You can use basic data literals including numbers (42
), strings ("hello"
), booleans (true
, false
), objects ({a: 1}
), and lists ([1, 2, 3]
).
Inputs: Add inputs to your expression by simply writing an identifier name (e.g., inputValue
). This adds an additional input property underneath the input you placed the expression in.
Indexing and calls: Use [index]
to access list or object properties and ()
to call functions. Note: Functions must currently be passed in as inputs to be called in expressions.
String interpolation: Embed expressions inside strings using ${...}
syntax. For example: "Hello, ${name}!"
.
Use : Local variables can be retrieved by prefixing their name with @
, e.g. @myVariable
.
Expressions currently cannot be used directly inside object literals—this will be added in a future update. See the guide for more information about how you can work around this limitation for now.