Line | Count | Source |
1 | // | |
2 | // Collection+Safe.swift | |
3 | // CutBox | |
4 | // | |
5 | // Created by Jason Milkins on 25/3/18. | |
6 | // Copyright © 2018-2023 ocodo. All rights reserved. | |
7 | // | |
8 | ||
9 | import Foundation | |
10 | ||
11 | extension Array { | |
12 | 153 | subscript(safe index: Int) -> Element? { |
13 | 153 | let inRange = index < self.count && index > -1 |
14 | 153 | return inRange ? self[index] : nil |
15 | 153 | } |
16 | } |