Debian Codegraph @

examples/array/foreach-auto2.ck

raw
1 //-------------------------------------------------------
2 // name: foreach-auto2.ck
3 // desc: iterating over multi-dimensional arrays
4 //. using for-each and auto
5 //
6 // requires: chuck-1.5.0.8 or higher
7 //-------------------------------------------------------
8
9 // a multi dimensional array
10 int array[2][0];
11
12 // fill the two arrays
13 array[0] << 1 << 2;
14 array[1] << 3 << 4;
15
16 // loop over outer array
17 for( auto x[] : array )
18 {
19 // loop over inner array
20 for( int y : x )
21 {
22 <<< y >>>;
23 }
24 }