Files
xcodesApp-mirror/Xcodes/Backend/Collection+.swift
2022-04-12 20:11:42 -05:00

18 lines
404 B
Swift

//
// Collection+.swift
// Xcodes
//
// Created by Matt Kiazyk on 2022-04-11.
// Copyright © 2022 Robots and Pencils. All rights reserved.
//
import Foundation
public extension Collection {
/// Returns the element at the specified index iff it is within bounds, otherwise nil.
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}