Swift Array – Check if an index exists

An elegant way in Swift:

let isIndexValid = array.indices.contains(index)

Leave a Comment