Avatar ·

How to find the index of an element in an array in Swift?

Hello everyone! I just started learning Swift, and I have a problem with finding the index of an element in an array. Let's say I have an array of strings with names: ```swift let names = ["Anna", "Boris", "Victor", "Galina", "Dmitry"] ``` I need to find out at which position the name "Victor" is. In other languages, like JavaScript, I would just use the `indexOf()` method. But in Swift, I can't find anything similar. I tried writing a loop manually: ```swift func findIndex(of name: String, in array: [String]) -> Int? { for i in 0..