Docs rewrite
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
---
|
||||
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";
|
||||
```
|
||||
Reference in New Issue
Block a user