Array
@frozen
public extension Array where Element == MonetaryAmount
-
Consolidates
MonetaryAmountvalues.MonetaryAmountvalues that have the sameCurrencywill be added together,MonetaryAmountvalues with uniqueCurrencyvalues will be added to the result on their own.Example
let moneyA = 12.00.in(.USD) let moneyB = 18.00.in(.USD) let moneyC = 6.00.in(.GBP) // result would equal [30.00.in(.USD), 6.00.in(.GBP)] let result = [moneyA, moneyB, moneyC].consolidating(moneyB)Declaration
Swift
func consolidated() -> [MonetaryAmount]Return Value
The a consolidated array of
MonetaryAmountvalues -
Consolidates a
MonetaryAmountvalue with thisMonetaryAmountarrayThis is functionally equivalent of the
Array<MonetaryAmount>.consolidated()instance method.See the documentation for the instance method
Array<MonetaryAmount>.consolidated()for more information.Declaration
Swift
func consolidating(_ monetaryAmount: MonetaryAmount) -> [MonetaryAmount] -
Consolidates a
MonetaryAmountvalue with thisMonetaryAmountarray. This is an alias for theconsolidating(_:)instance method.This is functionally equivalent of the
Array<MonetaryAmount>.consolidated()instance method.See the documentation for the instance method
Array<MonetaryAmount>.consolidated()for more information.Declaration
Swift
func adding(_ monetaryAmount: MonetaryAmount) -> [MonetaryAmount]
-
Consolidates two
MonetaryAmountarraysThis is functionally equivalent of the
Array<MonetaryAmount>.consolidated()instance method.See the documentation for the instance method
Array<MonetaryAmount>.consolidated()for more information.Declaration
Swift
static func | (lhs: [MonetaryAmount], rhs: [MonetaryAmount]) -> [MonetaryAmount]
-
Declaration
Swift
func negated() -> [MonetaryAmount]Return Value
A new
MonetaryAmountarray where all elements have been negated.
View on GitHub
Array Extension Reference