Skip to content

Keywords

Conditionals

Functions

  • fn: This is a function definition.
  • try: This is a keyword that is required to call a function that may throw. It doesn't do anything specific on its own, however it makes it clear to someone reading the code that the function they're calling could throw. It also colors the function it's being called in, and that containing function also becomes a throwing function. See error handling for details.

Types

  • bool: This is a builtin type for booleans.
  • byte: This is a builtin type for bytes.
  • char: This is a builtin type for characters.
  • complex: This is a builtin type for complex numbers.
  • decimal: This is a builtin type for decimal numbers.
  • enum: This is a keyword for defining enums.
  • error: This is a builtin type for errors.
  • int, uint, bigint: These are builtin types for integers.
  • str: This is a builtin type for strings.
  • struct: This is a keyword for defining structs.
  • type: This is a keyword for defining types.
  • union: This is a keyword for defining a union type.
  • mut: This keyword allows a value to be mutable. It can be used with any type.

Loops

  • for, in: These are used in for loops. The for signifies that it's a for loop, the value before in creates a variable that gets the value for each iteration of the loop, and the value after in is the array over which the loop is iterating.
  • while: This is used in while loops. The while signifies that it's a while loop, and the condition after while is checked each time the loop is run. If the condition is true, the loop continues, if not, it breaks and the program continues execution after the loop.
  • break, continue: These are used to break and continue loops, and can optionally be used with labels. See Labels, break, and continue.

Modules

  • import: This is used to import modules from other files or libraries.
  • as: This is used to alias imports to give them custom names, instead of depending on the filename.

Other

  • return: This is used to return values from a block. This can be returning values from a function, or returning a value from a conditional block into a variable, like an if-else statement or match statement.