Mojo language reference
Welcome to the Mojo language reference. This documentation provides a concise reference for Mojo's syntax—identifiers, keywords, literals, expressions, operators, statements, function declarations, and more. It's organized by grammar construct and is designed for quick lookup when you need the exact rules, precedence, or form of a specific language element.
Identifiers & keywords
Naming rules, reserved words, escaped identifiers, and argument conventions
Literals
Integer, floating-point, string, t-string, boolean, None, and Self literals
Expressions
Tuples, collection displays, member access, calls, subscripts, ternary conditionals, and comprehensions
Operators
Operator precedence, associativity, and implementing operators for custom types
Simple statements
Imports, assignments, return, raise, break, continue, and compile-time declarations
Compound statements
If statements, loops, error handling with try/except, context managers, and compile-time control flow
Function declarations
Signatures, parameters, arguments, default values, constraints, effects, and special methods