Skip to content

Commit

Permalink
Clarify what a 'generator' is in a couple of spots
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Hong committed Mar 1, 2024
1 parent a02b6c9 commit 608059b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _overviews/scala3-book/control-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 2 additions & 1 deletion _overviews/scala3-book/taste-control-structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand Down

0 comments on commit 608059b

Please sign in to comment.