YMSafeSubscriptable

public protocol YMSafeSubscriptable : Collection

Adopt this protocol to prevent out-of-bounds-class errors in collections.

  • subscript(safe:) Default implementation

    Allows subscripting collections in a safe manner, without out-of-bounds exceptions.

    • This protocol has a default implementation.

    Default Implementation

    Declaration

    Swift

    subscript(safe index: Index) -> Element? { get }

    Parameters

    index

    The index of an element.

    Return Value

    The element with the specified index, if such an element exists; otherwise, nil.