From 1bc39d21853c4fe869a6861354c54d213cd624bf Mon Sep 17 00:00:00 2001 From: Philip Ridgeway Date: Sat, 10 Mar 2018 10:57:39 -0800 Subject: [PATCH] Replaces references to indexOf(_:) with index(of:). The global function `indexOf(_:)` was replaced with `Collection.index(of:)` in Swift 2. --- Binary Search/README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Binary Search/README.markdown b/Binary Search/README.markdown index 09b141e04..0cecce6cf 100644 --- a/Binary Search/README.markdown +++ b/Binary Search/README.markdown @@ -4,15 +4,15 @@ Goal: Quickly find an element in an array. 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. -In most cases, Swift's `indexOf()` function is good enough for that: +In most cases, Swift's `Collection.index(of:)` function is good enough for that: ```swift let numbers = [11, 59, 3, 2, 53, 17, 31, 7, 19, 67, 47, 13, 37, 61, 29, 43, 5, 41, 23] -numbers.indexOf(43) // returns 15 +numbers.index(of: 43) // returns 15 ``` -The built-in `indexOf()` function performs a [linear search](../Linear%20Search/). In code that looks something like this: +The built-in `Collection.index(of:)` function performs a [linear search](../Linear%20Search/). In code that looks something like this: ```swift func linearSearch(_ a: [T], _ key: T) -> Int? {