Skip to content

Instantly share code, notes, and snippets.

@txaiwieser
Created June 1, 2015 18:01
Show Gist options
  • Save txaiwieser/948f6d482aa1a16549a7 to your computer and use it in GitHub Desktop.
Save txaiwieser/948f6d482aa1a16549a7 to your computer and use it in GitHub Desktop.
Array+SafeSubscript
//
// 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