Skip to content

Commit c9582ba

Browse files
committed
update iter.zen to use closures
1 parent ad06933 commit c9582ba

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/iter.zen

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
mod stdlib;
22

33
fn iter arr func {
4+
let arr = clone(arr);
45
while array_size(arr) > 0 {
56
if func(arr[0]) == false {
67
return null;
@@ -11,12 +12,10 @@ fn iter arr func {
1112
return null;
1213
}
1314

14-
fn print_item item {
15-
println(item);
16-
return true;
17-
}
18-
1915
fn main {
20-
iter([1,2,3,4,5], print_item);
16+
iter([1,2,3,4,5], fn item {
17+
println(item);
18+
return true;
19+
});
2120
return null;
2221
}

0 commit comments

Comments
 (0)