2011-06-15 13:19:50 -05:00
|
|
|
|
|
|
|
|
2010-06-23 23:03:09 -05:00
|
|
|
fn main() {
|
2011-07-27 07:19:39 -05:00
|
|
|
let x = [1, 2, 3];
|
|
|
|
let y = 0;
|
|
|
|
for i: int in x { log i; y += i; }
|
2011-06-15 13:19:50 -05:00
|
|
|
log y;
|
|
|
|
assert (y == 6);
|
2011-07-27 07:19:39 -05:00
|
|
|
let s = "hello there";
|
|
|
|
let i: int = 0;
|
|
|
|
for c: u8 in s {
|
|
|
|
if i == 0 { assert (c == 'h' as u8); }
|
|
|
|
if i == 1 { assert (c == 'e' as u8); }
|
|
|
|
if i == 2 { assert (c == 'l' as u8); }
|
|
|
|
if i == 3 { assert (c == 'l' as u8); }
|
|
|
|
if i == 4 { assert (c == 'o' as u8); }
|
2011-06-15 13:19:50 -05:00
|
|
|
// ...
|
2010-06-23 23:03:09 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
i += 1;
|
|
|
|
log i;
|
|
|
|
log c;
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|
2011-06-15 13:19:50 -05:00
|
|
|
assert (i == 11);
|
|
|
|
}
|