Array

public extension Array
  • Adds the given value at the beginning of the array

    Declaration

    Swift

    @discardableResult
    mutating func prepend(_ element: Element) -> Array<Element>

    Parameters

    element

    new element that needs to be added

    Return Value

    Self

  • Adds the given array items at the beginning of the array

    Declaration

    Swift

    @discardableResult
    mutating func prepend(_ elements: [Element]) -> Array<Element>

    Parameters

    elements

    new elements array that needs to be added

    Return Value

    Self

  • Safely deletes the item at the given index

    Declaration

    Swift

    @discardableResult
    mutating func safeDelete(at index: Int) -> Element?

    Parameters

    index

    at which items should be deleted

    Return Value

    Self or nil if given index is invalid