Skip to content

Commit

Permalink
allow array index writing
Browse files Browse the repository at this point in the history
  • Loading branch information
xhliu committed Apr 24, 2022
1 parent dae9348 commit 687b823
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions docs/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,11 @@ An array is a fixed-size list of values of the same basic type.
int d = a[2];
a[1] = -4;
int idx = 2;
// variable index is allowed when reading an array
// read
d = a[idx];
d = arr2D[idx][1];
// variable index is disallowed when writing into an array
// write
a[idx] = 2;
// only a compile-time constant (CTC) can be used as an index when writing
a[2] = 2;
a[N] = 3; // N is a CTC
// assign to an array variable
a = arr2D[1];
// b is a new copy and the same as a
Expand Down

0 comments on commit 687b823

Please sign in to comment.