Created
June 1, 2015 18:01
-
-
Save txaiwieser/948f6d482aa1a16549a7 to your computer and use it in GitHub Desktop.
Array+SafeSubscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Array+SafeSubscript.swift | |
// | |
// | |
// Created by Txai Wieser on 29/06/15. | |
// | |
// | |
import Foundation | |
extension Array { | |
subscript (safe index: UInt) -> Element? { | |
return Int(index) < count ? self[Int(index)] : nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment