| 1 |
// an array |
| 2 |
[1,3,4] @=> int array[]; |
| 3 |
|
| 4 |
// should be 3 |
| 5 |
array[1] => int three; |
| 6 |
|
| 7 |
// zero out the array, leaving size as is |
| 8 |
array.zero(); |
| 9 |
|
| 10 |
// print (should be three 3s) |
| 11 |
<<< three, array.size(), array[1] >>>; |
| 12 |
|
| 13 |
// using .zero() with multidimensional arrays |
| 14 |
// NOTE: requires chuck-1.5.5.1 or higher |
| 15 |
[ [1,2], [3,4] ] @=> int array2[][]; |
| 16 |
|
| 17 |
// zero out the multidimensional array, leaving size as is |
| 18 |
array2.zero(); |
| 19 |
|
| 20 |
// iterate over array2 |
| 21 |
for( int inner[] : array2 ) |
| 22 |
{ |
| 23 |
// iterate over each inner array |
| 24 |
for( int x: inner ) |
| 25 |
{ |
| 26 |
// print each element within |
| 27 |
cherr <= x <= " "; |
| 28 |
} |
| 29 |
} |
| 30 |
// print newline |
| 31 |
cherr <= IO.nl(); |
| 32 |
|
| 33 |
|