Let’s say you have an array of Customer objects.

struct Customer {
    var id: Int
    var firstName: String?
    var lastName: String?
}

var customerArray = [
    Customer(id: 0, firstName: "Nelson", lastName: "Mandela"),
    Customer(id: 1, firstName: "Elon", lastName: "Musk"),
    Customer(id: 2, firstName: "Hanya", lastName: "Yanigihara"),
    Customer(id: 3, firstName: "Oprah", lastName: "Winfrey"),
    Customer(id: 4, firstName: "Deepak", lastName: "Choprah")
]

You use this array of users to build a TableView and the user can reorder the list.

To remove a customer from the array without any possibility of encountering Out of Bounds (which of course will cause the App to crash) you need to safely remove items without knowing the index.

if let foundIndex = customerArray.firstIndex(where: { (thisCustomer) -> Bool in
    return thisCustomer.id == customerToRemove.id
}) {
    customerArray.remove(at: foundIndex)
}

I think this is a clever and (and Swifty!) way to write this.