1
0
forked from Mirror/wren

Added Sequence.each

This is a bit of a style preference since of course you can always write
the same thing with a for loop. However, I think sometimes the code
looks better when using this method.

It also provides an alternative to Sequence.map for cases where you
don't need the resulting list, and one that becomes especially necessary
when Sequence.map is changed to return a new sequence. The example in
the README.md file was using Sequence.map in a way that required this
alternative in that case.
This commit is contained in:
Thorbjørn Lindeijer
2015-03-28 20:35:20 +01:00
parent a7fafce265
commit c00d6ad694
8 changed files with 29 additions and 3 deletions

View File

@ -13,7 +13,7 @@ class Wren {
}
var adjectives = new Fiber {
["small", "clean", "fast"].map {|word| Fiber.yield(word) }
["small", "clean", "fast"].each {|word| Fiber.yield(word) }
}
while (!adjectives.isDone) IO.print(adjectives.call())