Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/language/03_data_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ let m = Matrix::[2, 2] { data: [0, 1, 2, 3] };
Note that generic structs cannot currently be imported outside a program, but can be declared and used in submodules. Acceptable types for const generic parameters include integer types, `bool`, `scalar`, `group`, `field`, and `address`.

## Option Types
As of v3.3.0, Leo supports first-class option types using the `T?` syntax, where `T` is any of the types previously mentioned, exlucding `address`, `signature`, and `tuple`. A value of type `T?` can be initialized into two states: either a value of type `T`, or `none`:
As of v3.3.0, Leo supports first-class option types using the `T?` syntax, where `T` is any of the types previously mentioned, excluding `address`, `signature`, and `tuple`. A value of type `T?` can be initialized into two states: either a value of type `T`, or `none`:
```leo
let w: u8? = 42u8;
let x: u8? = none;
Expand Down
30 changes: 15 additions & 15 deletions documentation/language/06_programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,38 +117,38 @@ Storage variable operations are only allowed in an [async function](#async-funct

Storage vectors behave like dynamic arrays of values of a given types. There are several functions available to query and modify storage vectors. The examples below will reference the following:
```leo
storage users: [address];
storage id_numbers: [u64];
```

### Querying
To query the address currrently stored in `users` at index `idx`:
To query the element currrently stored in `id_numbers` at index `idx`:
```leo
users.get(idx);
id_numbers.get(idx);
```
To get the current length of `users`:
To get the current length of `id_numbers`:
```leo
users.len();
id_numbers.len();
```
### Modifying
To set an address for at index `idx` in `users`:
To set an element at index `idx` in `id_numbers`:
```leo
users.set(idx, value);
id_numbers.set(idx, value);
```
To push an address onto the end of `users`:
To push an element onto the end of `id_numbers`:
```leo
users.push(value);
id_numbers.push(value);
```
To pop and return the last element of `users`:
To pop and return the last element of `id_numbers`:
```leo
users.pop();
id_numbers.pop();
```
To remove the element at index `idx`, return it, and replace it with the final element of `users`:
To remove the element at index `idx`, return it, and replace it with the final element of `id_numbers`:
```leo
users.swap_remove(idx);
id_numbers.swap_remove(idx);
```
To clear the every element in `users`:
To clear the every element in `id_numbers`:
```leo
users.clear()
id_numbers.clear()
```
:::note
- `clear()` does not actually remove any values from the vector. It just sets the length to 0.
Expand Down