Skip to content

Commit a95080a

Browse files
authored
Fixed typo in Views section of Collections Rework
1 parent 4645a7d commit a95080a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

_posts/2017-02-28-collections-rework.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ This has the advantage that we can overload `to` to cover maps (and maybe also o
138138

139139
## Views
140140

141-
[Views](https://docs.scala-lang.org/overviews/collections/views.html) in the current collections library [are one of the lesser-used features](https://github.com/scala/collection-strawman/issues/21#issuecomment-275861238) yet they add a lot of complexity to the implementation. The new design separates immutable views from mutable views (the latter have not yet been implemented), with only two types of immutable views: indexed and non-indexed. This is a huge simplification over the current design where a view type is specific to a its underlying collection type.
141+
[Views](https://docs.scala-lang.org/overviews/collections/views.html) in the current collections library [are one of the lesser-used features](https://github.com/scala/collection-strawman/issues/21#issuecomment-275861238) yet they add a lot of complexity to the implementation. The new design separates immutable views from mutable views (the latter have not yet been implemented), with only two types of immutable views: indexed and non-indexed. This is a huge simplification over the current design where a view type is specific to its underlying collection type.
142142

143143
Conceptually a `View` is now a reified operation over an `Iterator`. Like a [Java 8 Stream](https://zeroturnaround.com/rebellabs/java-8-streams-cheat-sheet/) it has *terminal* operations which run the operation represented by the current `View` on a fresh `Iterator` (e.g. `foreach` and `foldLeft`) and *intermediate* operations which create a new `View` (e.g. `filter` and `flatMap`). This provides clear semantics even when used together with mutable collections: Composing views with intermediate operations is always independent of concurrent modifications to the underlying collection. Only when you call a terminal operation will the current state of the collection be used (by calling `iterator` on it).
144144

0 commit comments

Comments
 (0)