Skip to content

Commit 2b40383

Browse files
committed
Add static array indexing to example & mention bounds checks
1 parent 3a6e1a9 commit 2b40383

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spec/arrays.dd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ assert(a[2] == 3);
182182
a[2] = 4;
183183
assert(a[2] == 4);
184184
assert(a == [1,2,4]);
185+
//writeln(a[3]); // runtime error (unless bounds checks turned off)
186+
187+
int[2] b = [1,2];
188+
assert(b[1] == 2);
189+
//writeln(b[2]); // compile-time error, index out of bounds
185190
---------
186191
)
187192

0 commit comments

Comments
 (0)