seq.reduce(into:_:)

// declaration
func reduce<Result>(
    into initialResult: Result, 
    _ updateAccumulatingResult: (
        _ partialResult: inout Result,    // โญ๏ธ inout parameter
        Self.Element    
    ) throws -> ()                        // โญ๏ธ no return value
) rethrows -> Result

This method is preferred over reduce(_:_:) for efficiency when the result is a copy-on-write type, for example an Array or a Dictionary.

๐Ÿ‘‰ .reduce(into:_:)

๐Ÿ‘‰ stackoverflow

Last updated

Was this helpful?