2010-06-24 04:03:09 +00:00
|
|
|
fn main() {
|
2011-05-17 01:21:22 +00:00
|
|
|
auto x = [1,2,3];
|
2010-06-24 04:03:09 +00:00
|
|
|
auto y = 0;
|
|
|
|
for (int i in x) {
|
|
|
|
log i;
|
|
|
|
y += i;
|
|
|
|
}
|
|
|
|
log y;
|
2011-05-03 00:47:24 +00:00
|
|
|
assert (y == 6);
|
2010-06-24 04:03:09 +00:00
|
|
|
|
|
|
|
auto s = "hello there";
|
|
|
|
let int i = 0;
|
|
|
|
for (u8 c in s) {
|
|
|
|
if (i == 0) {
|
2011-05-03 00:47:24 +00:00
|
|
|
assert (c == ('h' as u8));
|
2010-06-24 04:03:09 +00:00
|
|
|
}
|
|
|
|
if (i == 1) {
|
2011-05-03 00:47:24 +00:00
|
|
|
assert (c == ('e' as u8));
|
2010-06-24 04:03:09 +00:00
|
|
|
}
|
|
|
|
if (i == 2) {
|
2011-05-03 00:47:24 +00:00
|
|
|
assert (c == ('l' as u8));
|
2010-06-24 04:03:09 +00:00
|
|
|
}
|
|
|
|
if (i == 3) {
|
2011-05-03 00:47:24 +00:00
|
|
|
assert (c == ('l' as u8));
|
2010-06-24 04:03:09 +00:00
|
|
|
}
|
|
|
|
if (i == 4) {
|
2011-05-03 00:47:24 +00:00
|
|
|
assert (c == ('o' as u8));
|
2010-06-24 04:03:09 +00:00
|
|
|
}
|
|
|
|
// ...
|
|
|
|
i += 1;
|
|
|
|
log i;
|
|
|
|
log c;
|
|
|
|
}
|
2011-05-03 00:47:24 +00:00
|
|
|
assert (i == 11);
|
2010-06-24 04:03:09 +00:00
|
|
|
}
|