Since the deprecation of C-style for loops in Swift 2.2 (and the removal in Swift 3),
several questions about the possible replacements were asked on Stack Overflow were asked on Stack Overflow. In most cases, a for .. in
loop
is the appropriate replacement:
And finally an example where you iterate over a linked list of network interfaces (compare How to get Ip address in swift How to get Ip address in swift):
Since the deprecation of C-style for loops in Swift 2.2 (and the removal in Swift 3),
several questions about the possible replacements were asked on Stack Overflow. In most cases, a for .. in
loop
is the appropriate replacement:
And finally an example where you iterate over a linked list of network interfaces (compare How to get Ip address in swift):
Since the deprecation of C-style for loops in Swift 2.2 (and the removal in Swift 3),
several questions about the possible replacements were asked on Stack Overflow. In most cases, a for .. in
loop
is the appropriate replacement:
And finally an example where you iterate over a linked list of network interfaces (compare How to get Ip address in swift):
- The stride (advance) is not constant.
- The terminating condition is "dynamic" (depends on the loop variable), as in Swift replacement for C's for-loop Swift replacement for C's for-loop.
- The loop variable is not a strideable type (e.g. a linked list).
However, this has some disadvantages (and I cannot formulate it better than @nhgrif did in Swift replacement for C's for-loop Swift replacement for C's for-loop):
- The stride (advance) is not constant.
- The terminating condition is "dynamic" (depends on the loop variable), as in Swift replacement for C's for-loop.
- The loop variable is not a strideable type (e.g. a linked list).
However, this has some disadvantages (and I cannot formulate it better than @nhgrif did in Swift replacement for C's for-loop):
- The stride (advance) is not constant.
- The terminating condition is "dynamic" (depends on the loop variable), as in Swift replacement for C's for-loop.
- The loop variable is not a strideable type (e.g. a linked list).
However, this has some disadvantages (and I cannot formulate it better than @nhgrif did in Swift replacement for C's for-loop):
However, this has some disadvantages (and I cannot formulate it better than @nhgrif did in Swift replacement for C's for-loop again):
However, this has some disadvantages (and I cannot formulate it better than @nhgrif did in Swift replacement for C's for-loop again):
However, this has some disadvantages (and I cannot formulate it better than @nhgrif did in Swift replacement for C's for-loop):