Skip to content

Commit 1bc39d2

Browse files
committed
Replaces references to indexOf(_:) with index(of:).
The global function `indexOf(_:)` was replaced with `Collection.index(of:)` in Swift 2.
1 parent 0a1ab85 commit 1bc39d2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Binary Search/README.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Goal: Quickly find an element in an array.
44

55
Let's say you have an array of numbers and you want to determine whether a specific number is in that array, and if so, at which index.
66

7-
In most cases, Swift's `indexOf()` function is good enough for that:
7+
In most cases, Swift's `Collection.index(of:)` function is good enough for that:
88

99
```swift
1010
let numbers = [11, 59, 3, 2, 53, 17, 31, 7, 19, 67, 47, 13, 37, 61, 29, 43, 5, 41, 23]
1111

12-
numbers.indexOf(43) // returns 15
12+
numbers.index(of: 43) // returns 15
1313
```
1414

15-
The built-in `indexOf()` function performs a [linear search](../Linear%20Search/). In code that looks something like this:
15+
The built-in `Collection.index(of:)` function performs a [linear search](../Linear%20Search/). In code that looks something like this:
1616

1717
```swift
1818
func linearSearch<T: Equatable>(_ a: [T], _ key: T) -> Int? {

0 commit comments

Comments
 (0)