Files
mist-website/content/docs/guide/variables.mdx
T
2026-07-03 10:23:45 +02:00

31 lines
764 B
Plaintext

---
title: Variables
description: Variable declarations, mutability, type annotations, and destructuring.
icon: Variable
---
```mist
let x = 42; // Type-inferred immutable
let mut y = 10; // Mutable variable
i32 z = 100; // Explicit type annotation
str& s = "hello"; // Typed string reference
bool b = true; // Typed boolean
f64 f = 3.14; // Typed float
let (a, b) = (1, "two"); // Destructuring
let (x, (y, z)) = (1, (2, 3)); // Nested destructuring
```
Variable declarations follow either of two forms:
```mist
let <pattern> [= <expr>];
<type> <pattern> [= <expr>];
```
### Const and Static
```mist
const MAX: i32 = 100;
static NAME: str& = "hello";
```