We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9f85804 + b7b6130 commit 61c9376Copy full SHA for 61c9376
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]
Linear Search/LinearSearch.playground/timeline.xctimeline
0 commit comments