Updated docs to new version
This commit is contained in:
@@ -5,14 +5,15 @@ 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
|
||||
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
|
||||
(i32, str&) as x, y = (1, "hello"); // Typed tuple destructuring
|
||||
let (a, b) = (1, "two"); // Destructuring
|
||||
let (x, (y, z)) = (1, (2, 3)); // Nested destructuring
|
||||
```
|
||||
|
||||
Variable declarations follow either of two forms:
|
||||
@@ -22,6 +23,16 @@ let <pattern> [= <expr>];
|
||||
<type> <pattern> [= <expr>];
|
||||
```
|
||||
|
||||
### Tuple Variable Declarations
|
||||
|
||||
Tuple variables can be declared with explicit type annotations using `as`:
|
||||
|
||||
```mist
|
||||
(i32, bool) (x, y) as = (1, true);
|
||||
|
||||
i32 a, b = (1, 2, 3);
|
||||
```
|
||||
|
||||
### Const and Static
|
||||
|
||||
```mist
|
||||
|
||||
Reference in New Issue
Block a user