Return value of findIndex is Optional<Int>

This commit is contained in:
Cory Forsyth 2019-12-02 16:57:13 -05:00 committed by GitHub
parent 06e05c4ce3
commit 88795664c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -904,7 +904,7 @@ func findIndex<T: Equatable>(array: [T], valueToFind: T) -> Int? {
} }
return nil return nil
} }
findIndex(array: [1, 2, 3, 4], valueToFind: 3) // 2 findIndex(array: [1, 2, 3, 4], valueToFind: 3) // Optional(2)
// You can extend types with generics as well // You can extend types with generics as well
extension Array where Array.Element == Int { extension Array where Array.Element == Int {