Still or again interest in optional iteration?

I process a lot of XML where e.g. you might want to iterate through the child elements of the first child of a section:

mySection.children.first?.children.forEach { block in … }

But I cannot write:

for block in mySection.children.first?.children { … }

Note: There also is another problem with the second code: The Swift compiler could not infer the type of block.

1 Like