Check out example codes for "get last element of array swift". It will help you in understanding the concepts better.

Code Example 1

if let last = a.last {
   print(last)
}

Code Example 2

let array = ["A", "B", "C", 1, 2, 3]
let size = array.count
last_element = array[size-1]
print(last_element)

Learn ReactJs, React Native from akashmittal.com