8000 Update iterators.md · fsky/scala.github.com@1100dcd · GitHub
[go: up one dir, main page]

Skip to content

Commit 1100dcd

Browse files
Harish HurchurnHarish Hurchurn
authored andcommitted
Update iterators.md
Fixed typo
1 parent 9b2453e commit 1100dcd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

overviews/collections/iterators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ As always, for-expressions can be used as an alternate syntax for expressions in
2424

2525
for (elem <- it) println(elem)
2626

27-
There's an important difference between the foreach method on iterators and the same method on traversable collections: When called to an iterator, `foreach` will leave the iterator at its end when it is done. So calling `next` again on the same iterator will fail with a `NoSuchElementException`. By contrast, when called on on a collection, `foreach` leaves the number of elements in the collection unchanged (unless the passed function adds to removes elements, but this is discouraged, because it may lead to surprising results).
27+
There's an important difference between the foreach method on iterators and the same method on traversable collections: When called on an iterator, `foreach` will leave the iterator at its end when it is done. So calling `next` again on the same iterator will fail with a `NoSuchElementException`. By contrast, when called on on a collection, `foreach` leaves the number of elements in the collection unchanged (unless the passed function adds to removes elements, but this is discouraged, because it may lead to surprising results).
2828

2929
The other operations that Iterator has in common with `Traversable` have the same property. For instance, iterators provide a `map` method, which returns a new iterator:
3030

0 commit comments

Comments
 (0)
0