For Loop Conversion in Swift

Hi, i have only seen for loop samples that involve indexes or using for item in items.

I come from a java background and i cannot seem to confirm if this can actually be converted to a swift for loop. thoughts?

for (EdgeNode edge = aet.topNode ; (edge != null); edge = edge.next)
Answered by Claude31 in 745220022

This for loop exist in C or other, not in Swift since Swift3. https://github.com/apple/swift-evolution/blob/main/proposals/0007-remove-c-style-for-loops.md

You need to use a different pattern.

See examples here: https://forums.kodeco.com/t/how-to-change-c-style-for-loop-to-swift/100180/2

Accepted Answer

This for loop exist in C or other, not in Swift since Swift3. https://github.com/apple/swift-evolution/blob/main/proposals/0007-remove-c-style-for-loops.md

You need to use a different pattern.

See examples here: https://forums.kodeco.com/t/how-to-change-c-style-for-loop-to-swift/100180/2

For Loop Conversion in Swift
 
 
Q