Debian Codegraph @

examples/array/foreach-5.ck

raw
1 //-------------------------------------------------------
2 // name: foreach-5.ck
3 // desc: foreach with Objects
4 //
5 // requires: chuck-1.5.0.8 or higher
6 //-------------------------------------------------------
7
8 // create empty array
9 SinOsc array[5];
10
11 // number
12 110 => float f;
13
14 // for each element 'x' in array
15 for( SinOsc x : array )
16 {
17 // set the frequency
18 f => x.freq;
19 // double it
20 2 *=> f;
21 }
22
23
24 // a second loop for testing's sake
25 // (also using Osc, a parent of SinOsc to iterate)
26 for( Osc x : array )
27 {
28 // print
29 <<< x.freq() >>>;
30 }