Skip to content

Commit

Permalink
Merge pull request #313 from AleoHQ/feat/tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
a h authored Nov 8, 2023
2 parents b80241e + 6b40554 commit 6d4affc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion documentation/leo/03_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ record token {

### Array

Leo supports static arrays. Arrays are declared as `[type; length]`. Arrays cannot be empty nor modified.
Leo supports static arrays. Arrays are declared as `[type; length]` and can be nested. Arrays cannot be empty nor modified.

Arrays only support constant accesses (the index must be a constant value). The accessor value must be a constant integer.

Expand Down Expand Up @@ -329,6 +329,24 @@ transition sum_with_loop(a: [u64; 4]) -> u64 {
}
```

### Tuple

Leo supports tuples. Tuples are declared as `(type1, type2, ...)` and can be nested. Tuples cannot be empty nor modified.

Tuples only support constant access with a dot `.` and a constant integer.

Tuples can contain primitive data types, structs, or arrays. Structs and records can also contain tuples.

```leo
program test.aleo {
transition baz(foo: u8, bar: u8) -> u8 {
let a: (u8, u8) = (foo, bar);
let result: u8 = a.0 + a.1;
return result;
}
}
```

### Transition Function

Transition functions in Leo are declared as `transition {name}() {}`.
Expand Down

0 comments on commit 6d4affc

Please sign in to comment.