Answers for "index and element swift"

2

swift for loop index

for (index, object) in list.enumerated() {
  print("Item at \(index): \(object)")
}
Posted by: Guest on September-29-2020
1

How to find index of list item in Swift?

let arr = ["a","b","c","a"]

let indexOfA = arr.firstIndex(of: "a") // 0
let indexOfB = arr.lastIndex(of: "a") // 3
Posted by: Guest on January-30-2020

Code answers related to "index and element swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language