History

new example array_zero.ck and corresponding test 119.ck

Ge Wang committed 3 years ago

Commit 77e9c401 parent dab707e2 files · +26 −0Browse files

Unified · Split

2 files
  1. examples/array/array_zero.ck +14 −0
  2. src/test/01-Basic/119.ck +12 −0
examples/array/array_zero.ck+14−0
@@ -0,0 +1,14 @@
1// .zero() zeros out the contents AND keeps size unchanged
2// version: need chuck-1.4.2.1 or higher
3
4// an array
5[1,3,4] @=> int array[];
6
7// should print 3 3
8<<< array[1], array.size() >>>;
9
10// zero out the array, leaving size as is
11array.zero();
12
13// now should print 0 3
14<<< array[1], array.size() >>>;
src/test/01-Basic/119.ck+12−0
@@ -0,0 +1,12 @@
1// an array
2[1,3,4] @=> int array[];
3
4// should be 3
5array[1] => int three;
6
7// zero out the array, leaving size as is
8array.zero();
9
10// check: size should be 3 but array[1] should now be zero
11if( three == 3 && array.size() == 3 && array[1] == 0 )
12 <<< "success" >>>;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t