8000 Merge pull request #200 from nemanjavlahovic/linear-search-nemanja · lina1/swift-algorithm-club@59314d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59314d4

Browse files
author
Chris Pilcher
authored
Merge pull request kodecocodes#200 from nemanjavlahovic/linear-search-nemanja
Updating Linear Search to Swift 3
2 parents 6fb02e3 + 33b6e65 commit 59314d4

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Linear Search/LinearSearch.playground/Contents.swift

Lines changed: 2 additions & 2 deletions
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

Linear Search/LinearSearch.swift

-2Lines changed: 2 additions & 2 deletions
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

Linear Search/README.markdown

Lines changed: 2 additions & 2 deletions
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)
0