Skip to content

Commit 33b6e65

Browse files
committed
Update Linear Search to Swift 3
1 parent 8f04475 commit 33b6e65

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Diff for: Linear Search/LinearSearch.playground/Contents.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//: Playground - noun: a place where people can play
22

3-
func linearSearch<T: Equatable>(array: [T], _ object: T) -> Int? {
4-
for (index, obj) in array.enumerate() where obj == object {
3+
func linearSearch<T: Equatable>(_ array: [T], _ object: T) -> Int? {
4+
for (index, obj) in array.enumerated() where obj == object {
55
return index
66
}
77
return nil

Diff for: Linear Search/LinearSearch.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
func linearSearch<T: Equatable>(array: [T], _ object: T) -> Int? {
2-
for (index, obj) in array.enumerate() where obj == object {
1+
func linearSearch<T: Equatable>(_ array: [T], _ object: T) -> Int? {
2+
for (index, obj) in array.enumerated() where obj == object {
33
return index
44
}
55
return nil

Diff for: Linear Search/README.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ We compare the number `2` from the array to our number `2` and notice they are e
1717
Here is a simple implementation of linear search in Swift:
1818

1919
```swift
20-
func linearSearch<T: Equatable>(array: [T], _ object: T) -> Int? {
21-
for (index, obj) in array.enumerate() where obj == object {
20+
func linearSearch<T: Equatable>(_ array: [T], _ object: T) -> Int? {
21+
for (index, obj) in array.enumerated() where obj == object {
2222
return index
2323
}
2424
return nil

0 commit comments

Comments
 (0)