examples/array/foreach-auto1.ck
raw| 1 | //------------------------------------------------------- |
| 2 | // name: foreach-auto1.ck |
| 3 | // desc: using for-each construct with auto type |
| 4 | // |
| 5 | // requires: chuck-1.5.0.8 or higher |
| 6 | //------------------------------------------------------- |
| 7 | |
| 8 | // create array |
| 9 | [1,2,3] @=> int array[]; |
| 10 | |
| 11 | // for each element 'x' in array |
| 12 | for( auto x : array ) |
| 13 | { |
| 14 | // print the element |
| 15 | <<< x >>>; |
| 16 | } |