reduce() vs. reduce(into:)
`reduce(_:_:)``reduce(into:_:)`
// `reduce(_:_:)`
func reduce<Result>(
_ initialResult : Result,
// ⭐️ combine function (with return value)
_ nextPartialResult: (Result, Element) throws -> Result
) rethrows -> Result
// `reduce(into:_:)`
func reduce<Result>(
into initialResult: Result,
_ updateAccumulatingResult: (
_ partialResult: inout Result, // ⭐️ inout parameter
Self.Element
) throws -> () // ⭐️ no return value
) rethrows -> ResultExample
.reduce()
.reduce(into:)
Last updated