Sep-26-2020, 11:43 AM
"Yield" is useful in separating concerns. It separates the code that creates a collection of similar entities from the code that uses this collection. You can decide to print these items or store them in a container or whatever, but the function that generates the items doesn't need to know what you are going to do with them. Its sole responsibility is the production of these items.