Array

extension Array
  • Returns an array containing the results of mapping the given closure over the sequence’s elements and force unwrapping Optional values.

    let values: [Int?] = [1, 2, 3, nil]
    let unwrapped: [Int] = values.map(forceUnwrapMap)
    

    Throws

    Rethrows errors of the transformation function

    Declaration

    Swift

    @inlinable
    public func forceUnwrapMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]

    Parameters

    transform

    A mapping closure. transform accepts an element of this sequence as its parameter and returns a transformed value of the same or of a different type.

    Return Value

    An non-optional array containing the transformed elements of this sequence.