Need help?
Ask a question or report a problem on GitHub.
Open an issue
Conditions
if and otherwise choose what runs. Indentation defines the block; a period finishes it. There are no braces and no end keyword.
Otter
age is 20 if age is at least 18 say "Adult" otherwise say "Minor" .
Output
Adult
Comparison words
PowerShell
is equal to is not not equal to is greater than greater than is at least greater than or equal to is less than less than is at most less than or equal to
Each side of a comparison can be a calculation: if price plus tax is at least 100 works out price plus tax first, reading left to right as in any other calculation. The word and between two comparisons still means both, so if x is 4 and y is 5 is two comparisons.
Chaining conditions
Test several branches with otherwise if:
Otter
score is 85 if score is at least 90 say "Grade: A" otherwise if score is at least 80 say "Grade: B" otherwise say "Grade: C" .
Output
Grade: B
Truthiness
A condition can also be a plain value. Text and lists are true when they are not empty, numbers are true when they are not zero, and gone is false. A variable that does not exist is an error - never silently false.
Recovering from errors
try runs a block; if something in it fails, the otherwise block runs instead of stopping the program. otherwise is optional: without it, the failure is ignored and the program continues after the try block.
The period after a block is optional where indentation is already unambiguous, and it makes nested code explicit. It is never used for property access.
Next: loops