Array.index(where: { $0 == ... } returns "Array<Element>.Index" instead of an Int. Is there a way to get an Int ?
Thanks.
Array.index(where: { $0 == ... } returns "Array<Element>.Index" instead of an Int. Is there a way to get an Int ?
Thanks.
I tested the following
let listOfNames = ["aa", "bb", "cc"]
let index = listOfNames.index(where: { $0 == "bb" }) ?? -1 // becasue returns optional
print(index)
I get 1
What is your issue ?
I tested the following
let listOfNames = ["aa", "bb", "cc"]
let index = listOfNames.index(where: { $0 == "bb" }) ?? -1 // becasue returns optional
print(index)
I get 1
What is your issue ?
Works, thanks.