We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e0ae64 commit e390f59Copy full SHA for e390f59
Linear Search/LinearSearch.playground/Contents.swift
@@ -1,10 +1,15 @@
1
//: Playground - noun: a place where people can play
2
3
+// last checked with Xcode 4.0b4
4
+#if swift(>=4.0)
5
+print("Hello, Swift 4!")
6
+#endif
7
+
8
func linearSearch<T: Equatable>(_ array: [T], _ object: T) -> Int? {
- for (index, obj) in array.enumerated() where obj == object {
- return index
- }
- return nil
9
+ for (index, obj) in array.enumerated() where obj == object {
10
+ return index
11
+ }
12
+ return nil
13
}
14
15
let array = [5, 2, 4, 7]
0 commit comments