Making For Comprehensions
For comprehensions work by convention, there’s no requirement for them to be a collection.
- A single layer of nesting requires map to be implemented
- Multiple layers of nesting, requires map and flatMap to be implemented.
- If you want to filter items, implement filter.
- To just loop over elements, implement foreach.
❦
Contents
Making For Comprehensions