check enumatted arrray last item swift

Swift
    for (idx, element) in array.enumerated() {
      if idx == array.endIndex-1 {
        // handling the last element
       }
     }
Source

Also in Swift: