Array
@frozen
public extension Array where Element == MonetaryAmount
-
Consolidates
MonetaryAmount
values.MonetaryAmount
values that have the sameCurrency
will be added together,MonetaryAmount
values with uniqueCurrency
values 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
MonetaryAmount
values -
Consolidates a
MonetaryAmount
value with thisMonetaryAmount
arrayThis 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
MonetaryAmount
value with thisMonetaryAmount
array. 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
MonetaryAmount
arraysThis 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
MonetaryAmount
array where all elements have been negated.