src/test/01-Basic/140-foreach.ck
raw| 1 | //------------------------------------------------------- |
| 2 | // name: foreach-3.ck |
| 3 | // desc: nested for-each loops |
| 4 | // |
| 5 | // requires: chuck-1.5.0.8 or higher |
| 6 | //------------------------------------------------------- |
| 7 | |
| 8 | // two arrays |
| 9 | [1, 2, 3] @=> int foo[]; |
| 10 | [1, 2, 3] @=> int bar[]; |
| 11 | |
| 12 | // for each element in foo |
| 13 | for( int f : foo ) |
| 14 | { |
| 15 | // for each element in bar |
| 16 | for( int b : bar ) |
| 17 | { |
| 18 | // print the product |
| 19 | <<< f*b >>>; |
| 20 | } |
| 21 | } |