The function index of an Swift array returns the first element based on the condition inside the where clause. Is there a way to get the last element with this condition?
For example, I want something like this (I know there is no function called lastIndex. This function or similar is what I'm searching for):
let array = [1, 2, 3, 4, 5, 3, 6]
let indexOfLastElementEquals3 = array.lastIndex(where: { $0 == 3 })
print(indexOfLastElementEquals3) //5 (Optional)