//
// main.swift
// Ultimate
//
// Created by Mewlan Musajan on 4/26/21.
//
//Excerpt From: Apple Inc. “The Swift Programming Language (Swift 5.3).” Apple Books. https://books.apple.com/us/book/the-swift-programming-language-swift-5-3/id881256329
func findAnyTypeOfIndex<T: Equatable>(of valueToFind: T, in array:[T]) -> Int? {
for (index, value) in array.enumerated() {
if value == valueToFind {
return index
}
}
return nil
}
let someIntValues = [1, 2, 3, 4, 5]
if let intValue = findAnyTypeOfIndex(of: 2, in: someIntValues) {
print(intValue)
}