Need help?
Ask a question or report a problem on GitHub.
Open an issue
Values and variables
Otter works with text, numbers, booleans, lists, objects, and gone. Use is to give a value a name.
Otter
name is "Alice" age is 29 ratio is 3.14 active is true missing is gone
Variable names start with a lowercase letter and use camelCase (totalRevenue, userEmail). Names are case-sensitive. Text uses double quotes. Types are determined automatically.
Saying values
say prints its values on one line, separated by single spaces. Numbers print without trailing zeros and booleans as true or false.
Otter
name is "Jeff" age is 29 say name "is" age "years old."
Output
Jeff is 29 years old.
Arithmetic
Calculations use everyday words. make stores the result:
Otter
number1 is 10 number2 is 5 number1 and number2 make total number1 minus number2 make difference number1 times number2 make product number1 divided by number2 make quotient say "Total:" total say "Difference:" difference say "Product:" product say "Quotient:" quotient
Output
Total: 15 Difference: 5 Product: 50 Quotient: 2
Dividing by zero is a readable Otter error, never a crash.
Changing a number in place
Otter
score is 100 add 15 to score remove 30 from score say "Final score:" score
Output
Final score: 85
Input
ask converts what was typed: 42 becomes the number 42, true becomes a boolean, and everything else stays text.
Otter
ask "Enter your age: " and call it age age and 5 make futureAge say "In 5 years you will be:" futureAge
Using a variable that was never defined is an error, not false and not empty. Otter tells you which name it could not find.
Comments
A # starts a comment that runs to the end of the line. Comments are for people; Otter ignores them. A # inside quotes is just text.
Otter
# This whole line is a comment. age is 29 # so is the end of this line say "#1 is not a comment" say age
Good comments explain why, not what: the code already says what.
Next: conditions