diff --git a/_overviews/scala3-book/control-structures.md b/_overviews/scala3-book/control-structures.md index fe94b30dc..6598cb604 100644 --- a/_overviews/scala3-book/control-structures.md +++ b/_overviews/scala3-book/control-structures.md @@ -236,7 +236,7 @@ for i <- ints do println(i) {% endtabs %} -The code `i <- ints` is referred to as a _generator_. +The code `i <- ints` is referred to as a _generator_. In any generator `p <- e`, the expression `e` can generate zero or many bindings to the pattern `p`. This is what the result looks like in the Scala REPL: diff --git a/_overviews/scala3-book/taste-control-structures.md b/_overviews/scala3-book/taste-control-structures.md index 3427c2939..4b58abbf0 100644 --- a/_overviews/scala3-book/taste-control-structures.md +++ b/_overviews/scala3-book/taste-control-structures.md @@ -92,7 +92,8 @@ val ints = List(1, 2, 3, 4, 5) for (i <- ints) println(i) ``` -> The code `i <- ints` is referred to as a _generator_, and the code that follows the closing parentheses of the generator is the _body_ of the loop. +> The code `i <- ints` is referred to as a _generator_. In any generator `p <- e`, the expression `e` can generate zero or many bindings to the pattern `p`. +> The code that follows the closing parentheses of the generator is the _body_ of the loop. {% endtab %} diff --git a/_tour/for-comprehensions.md b/_tour/for-comprehensions.md index a21138023..a97758d8b 100644 --- a/_tour/for-comprehensions.md +++ b/_tour/for-comprehensions.md @@ -12,7 +12,7 @@ redirect_from: - "/tutorials/tour/sequence-comprehensions.html" --- -Scala offers a lightweight notation for expressing _sequence comprehensions_. Comprehensions have the form `for (enumerators) yield e`, where `enumerators` refers to a semicolon-separated list of enumerators. An _enumerator_ is either a generator which introduces new variables, or it is a filter. A comprehension evaluates the body `e` for each binding generated by the enumerators and returns a sequence of these values. +Scala offers a lightweight notation for expressing _sequence comprehensions_. Comprehensions have the form `for (enumerators) yield e`, where `enumerators` refers to a list of enumerators. An _enumerator_ is either a generator, or it is a guard (see: [Control Structures](/scala3/book/control-structures.html#for-loops)). A comprehension evaluates the body `e` for each binding generated by the enumerators and returns a sequence of these values. Here's an example: