I’m not sure if this was intended or not, but the downloadable example project is the API 1.0 edition and doesn’t match the article.
Another main difference is that you cannot continue through the loop if an exception is raised, unlike when using For… Next, see <https://xojo.com/issue/63699>
Just looking at the description of the Feedback case and the example. What is supposed to happen in the example? I clicked on the button… and nothing happened. Ok, so c:windows isn’t the best starting point for macOS. But even with specialFolder.Applications as starting point: what should I see?
You’ll only encounter the problem if a file in your search path isn’t accessible at which point an exception is thrown that you can’t iterate past, hence iterables being of limited use when exceptions are encountered.
In the example, it would be a file that doesn’t have correct privileges to access it, or the file has been (re)moved since the directory listing was obtained and the iterator hit the file.
If the internals of the iteration raise an exception, you cannot skip and carry on. If you break the iteration out into a standard for loop, you can indeed use try/catch as you can handle the skip and carry on yourself, thus rendering the use of iteration limited.
There’s something else I quite don’t get in the announcement.
Why would one add and use an iterator to get the addresses when it’s simply doable with “for each Address as PostalAddress in ThisPerson.Addresses”, since ThisPerson.Addresses is already an array (so, iterable)?