Quick Tour
This page presents a brief tour of basic Aura syntax and concepts. Where appropriate, sections will include a link to a page containing more detailed information.
Module Definition and Imports
All Aura source files must begin with a mod
declaration, and any imports should come immediately after.
Program Entrypoint
Every Aura project must define exactly one main
function, which is the project's entrypoint.
Printing to stdout
Printing to the standard output is done with functions exported by the io
standard library module
See Standard Library and io
module
Functions
Functions are defined with the fn
keyword. A typical declaration would look like:
See Functions
Variables
Variables can be defined with the let
keyword like so:
They can also be defined with shorter syntax that omits the let
keyword:
Variables are defined as immutable by default. To define a variable as mutable, use the mut
keyword:
See Variables
Classes and Structs
Classes are defined with the class
keyword, and can contain zero or more parameters and zero or more methods.
And structs are defined with the struct
keyword:
To create instances of classes and structs, their names are used in a function call:
Comments
Single line comments:
Multi-line comments:
See Comments
Conditional Expressions
if
expressions in Aura are expressions capable of returning a value, which is done with the yield
keyword.
See if
expressions
Loops
for
loops:
foreach
loops:
while
loops:
See Loops
Collections
Aura supports two collection types.