Set does have an iterator method; this is used internally by the for-in loop syntax. However, it does not implement the Iterable interface.
This notably means that new methods, like String.join, do not work with Sets, even though they have the iterator method.
As far as the documentation is concerned, I suspect that it's not documented because Set doesn't actually implement the Iterable interface. In other words, it's an internal method.
You'll also notice that other methods are not documented, either. For example, Object isn't documented, despite having two methods you can use (equals and hashCode).
I'm not sure you'd get a better answer short of having a real salesforce.com employee posting an answer.
Answer from sfdcfox on Stack ExchangeApex Hours
apexhours.com › home › salesforce release notes › preventing collection modification during iteration in apex (set) – winter’25 release
Preventing Collection Modification During Iteration in Apex (Set) - Winter’25 Release - Apex Hours
October 14, 2024 - In Apex, modifying a Set while iterating over it was previously allowed, but it often led to unpredictable behavior. Developers encountered issues such as skipped elements, multiple processes on the same element, or unexpected errors. To address this, from API version 61.0, Apex introduced a restriction that prevents modifying a Set during iteration.
Salesforce
help.salesforce.com › s › articleView
Iterate Within For Loops More Easily with Iterable | Salesforce Help
public class MyIterable implements Iterable<String> { public Iterator<String> iterator() { return new Set<String>{'Hello', 'World!'}.iterator(); } } for (String str : new MyIterable()) { System.debug(str); } IdeaExchange: Allow Iterable for Loops in Apex Code
Comrevo
comrevo.com › 2023 › 01 › apex-list-or-set-iteration-for-loops.html
Comrevo — Free Calculators + Tech Guides: Apex List or Set Iteration for Loops | For Each Loop | Enhanced or Range Based For Loop | Salesforce
January 8, 2023 - In this post, we will see Apex List or Set Iteration for Loops | For Each Loop | Enhanced or Range Based For Loop | Salesforce
Salesforce
ideas.salesforce.com › s › idea › a0B8W00000GdX2vUAF › apex-code-implement-iterable-on-set
Apex Code: Implement Iterable on Set. - IdeaExchange
Loading · ×Sorry to interrupt · Refresh
Blogger
salesforcecodes.blogspot.com › 2020 › 01 › how-to-use-custom-iterator-in-apex.html
Salesforce Codes: How to use custom iterator in apex batch class
Use a custom iterator defined using CustomIterable interface · You can just use standard apex collections like list as iterator.
YouTube
youtube.com › codeisha
Custom Iterator in Apex | Benefits, Methods & Code Example - YouTube
Learn everything about Custom Iterators in Apex:1. What is a Custom Iterator?2. Why should you use Custom Iterators?3. Where can you implement them?4. Key me...
Published: December 29, 2024
Views: 200
Salesforce
help.salesforce.com › s › articleView
Use the Iterable Interface with Set Type
Loading · ×Sorry to interrupt · Refresh