Data Types¶
Arx uses explicit type annotations for variables, function parameters, and function return types.
Type Annotations¶
- Function parameters must always be typed.
- Function return type is declared with
-> typeand is always required, including-> none. - Variable declarations must include an explicit type with
var name: type.
```
title: Typed function signature
summary: Demonstrates required parameter annotations.
```
fn add(a: i32, b: i32) -> i32:
```
title: add
summary: Returns a + b.
```
return a + b
Common Annotation Forms¶
fn summarize(name: str, values: list[i32]) -> none:
var count: i32 = 0
return
Common places where types appear:
- function parameters:
fn add(a: i32, b: i32) -> i32: - function return types:
fn test_add() -> none: - variable declarations:
var total: i32 = 0 - generic-style element annotations:
list[i32]
Built-in Type Reference¶
For the catalog of built-in types, aliases, and examples, see Built-in Types.
That page covers:
- numeric types and aliases
noneas the unit type and value- string, character, and temporal types
- lists and current limitations
- the
cast(value, type)helper