mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 10:01:38 +00:00
Merge pull request #3788 from bantic/patch-1
[swift/en] Return value of `findIndex` is `Optional<Int>`
This commit is contained in:
commit
16e416ab7f
@ -909,7 +909,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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user