Skip to content

Commit

Permalink
Merge pull request kodecocodes#566 from shabirjan/LinearSearch-Swift4
Browse files Browse the repository at this point in the history
Linear search Swift4
  • Loading branch information
vincentngo authored Aug 2, 2017
2 parents 9f85804 + b7b6130 commit 61c9376
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 9 additions & 4 deletions Linear Search/LinearSearch.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
//: Playground - noun: a place where people can play

// last checked with Xcode 4.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

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

let array = [5, 2, 4, 7]
Expand Down
6 changes: 0 additions & 6 deletions Linear Search/LinearSearch.playground/timeline.xctimeline

This file was deleted.

0 comments on commit 61c9376

Please sign in to comment.