Skip to content

Commit 608059b

Browse files
author
Ali Hong
committed
Clarify what a 'generator' is in a couple of spots
1 parent a02b6c9 commit 608059b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

_overviews/scala3-book/control-structures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ for i <- ints do println(i)
236236
{% endtabs %}
237237

238238

239-
The code `i <- ints` is referred to as a _generator_.
239+
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`.
240240

241241
This is what the result looks like in the Scala REPL:
242242

_overviews/scala3-book/taste-control-structures.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ val ints = List(1, 2, 3, 4, 5)
9292
for (i <- ints) println(i)
9393
```
9494

95-
> 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.
95+
> 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`.
96+
> The code that follows the closing parentheses of the generator is the _body_ of the loop.
9697
9798
{% endtab %}
9899

0 commit comments

Comments
 (0)