I want to start loop through array at index (say “5” or any other) instead of beginning of the array in swift
for (index, value) in array.enumerate() {
// do something
}
Join Stack Overflow to learn, share knowledge, and build your career.
I want to start loop through array at index (say “5” or any other) instead of beginning of the array in swift
for (index, value) in array.enumerate() {
// do something
}
Use dropFirst
to ignore the first items:
for (index, value) in array.enumerated().dropFirst(5) {
// your code here
}
Use the where
clause
for (index, value) in array.enumerate() where index > 4 { ...
By the way: Update your Swift version. Swift 2 is dead