let positions = [10, 20, 30, 40, 50, 60]
// Loop over elements and indexes in array.
for (index, element) in positions.enumerated() {
// See if index is even and not the last index.
if index % 2 == 0 && index + 1 < positions.count {
// Get adjacent elements.
let next = positions[index + 1]
print(
"\(element), \(next)")
}
}
10, 20
30, 40
50, 60