This commit is contained in:
parent
8f681d1605
commit
73c1a814f5
21
tests/loop_foreach_test.aer
Normal file
21
tests/loop_foreach_test.aer
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class Program {
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
int[] $numbers = {'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'zero' => 0};
|
||||||
|
string[] $days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
|
||||||
|
foreach(string $key => int $numeric in $numbers) {
|
||||||
|
if($numeric == 6) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
print("$key is $numeric\n");
|
||||||
|
if($numeric == 8) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print("\nA week has seven days:\n");
|
||||||
|
foreach(string $day in $days) {
|
||||||
|
print("$day\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
12
tests/loop_foreach_test.exp
Normal file
12
tests/loop_foreach_test.exp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
five is 5
|
||||||
|
seven is 7
|
||||||
|
eight is 8
|
||||||
|
|
||||||
|
A week has seven days:
|
||||||
|
Monday
|
||||||
|
Tuesday
|
||||||
|
Wednesday
|
||||||
|
Thursday
|
||||||
|
Friday
|
||||||
|
Saturday
|
||||||
|
Sunday
|
Loading…
Reference in New Issue
Block a user