Answers for "swift determine if element is last"

0

check enumatted arrray last item swift

for (idx, element) in array.enumerated() {
      if idx == array.endIndex-1 {
        // handling the last element
       }
     }
Posted by: Guest on September-24-2020
0

how to get last element of an array in swifg

let myArray = ["Hello!", "World!"]
let capacity = myArray.count
let lastElement = myArray[capacity-1]
print(lastElement)
Posted by: Guest on October-26-2020

Code answers related to "swift determine if element is last"

Code answers related to "Swift"

Browse Popular Code Answers by Language