Closed hongtron closed 6 months ago
Hey, thank you for opening this PR! We can definitely do more to make a reusable definition to explain what is meant by "generator". Probably the best is from this page
The code
i <- ints
is referred to as a generator.
Perhaps we can copy that to the tour and a taste of scala
My suggestion for improvement would be
The code
i <- ints
is referred to as a generator. In any generatorp <- e
, the expressione
can generate zero or many bindings to the patternp
.
Thank you for your feedback! I've pushed some changes to incorporate your definition, and update the other spots you called out.
I also made two other wording changes, which I've broken into separate commits for emphasis (one regarding the phrase "semicolon-separated," and one replacing "filter" with "guard"). Let me know if you think they make sense.
The term "generator" is used in a couple spots in the docs (e.g. in For Comprehensions in the Tour of Scala), but is never defined. As an alternative to this change, I welcome (and would even prefer) proposed definitions for the term, if the Scala concept does not completely line up with the wiki content - but I do not feel qualified to venture a definition myself.