With generics should come better for-loop support
It's unclear why the enhanced for-loop in Apex is restricted to only iterating over a Set or List, but perhaps the very narrow support for type parameters had something to do with it? With more complete support for generics, Salesforce should consider broadening the types that for-loops can iterate over, as captured in this Idea:
https://ideas.salesforce.com/s/idea/a0B8W00000GdYeuUAF/allow-iterable-for-loops-in-apex-code
Just posting this to hopefully plant some seeds or provide a gentle nudge!
2 comments