<^>(_:_:)
public func <^><T, U, Key: Hashable>(_ transform: (T) -> U,
_ arg: [Key: T]) -> [Key: U]
An infix synonym for map(_:)
.
The name of this operation is allusion to ^
. Note the similarities between their types:
(^) : (T -> U) T -> U
(<^>) : (T -> U) -> [V: T] -> [V: U]
Examples:
If you need transform all values of Dictionary
:
let jsonToPrice: (JSON) -> Price = ...
let data: [Currency: JSON] = ...
// paymentMethods is [Currency: Price]
let paymentMethods = jsonToPrice <^> data
-
Declaration
Swift
public func <^><T, U, Key: Hashable>(_ transform: (T) -> U, _ arg: [Key: T]) -> [Key: U]