Skip to content

Keywords

  • error: This is a builtin type for errors.
  • throw: This is a keyword that is used to throw an error. See errors for details.
  • catch: This is a keyword that allows you to capture an error thrown by a function. See errors for details.
  • fn: This is a function definition.
  • return: This is used to return values from a function.
  • bool: This is a builtin type for booleans.
  • byte: This is a builtin type for bytes.
  • char: This is a builtin type for characters.
  • enum: This is a keyword for defining enums.
  • int, uint: These are builtin types for integers.
  • float: This is a builtin type for floating point numbers.
  • str: This is a builtin type for strings.
  • struct: This is a keyword for defining structs.
  • interface, impl: These are keywords for defining and implementing interfaces.
  • type: This is a keyword for defining types.
  • void: This is a builtin empty type.
  • mut: This keyword allows a value to be mutable. It can be used with any type.
  • as: This keyword allows a value to be cast into another type.
  • 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 index 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.
  • import, as: This keyword allows you to import symbols from modules such as other files or libraries, and assign them to a given module name.
  • extern: This keyword declares external functions implemented outside NC.
  • pub: This keyword allows you to export symbols from a module to be used in other places.
  • fut: This creates a Future.
  • async: This marks a function call as asynchronous, and returns a Future. See async for details.
  • await: This awaits a Future to block execution until it resolves and gets a value out. See async for details.
  • mutex: This creates a Mutex.
  • lock: This locks a Mutex and creates a scope where it is mutable so only one thread can access and mutate it. If a thread has a lock, all other threads must wait until the lock is released and they can get their own lock.
  • test: This keyword allows you to define tests for your code.
  • assert: This keyword allows you to create conditions for your tests to pass or fail. It is only available as a keyword inside a test block.