Skip to content

Repository files navigation

MapSugar 🗺️

.package(url: "https://github.com/mesqueeb/MapSugar", from: "0.2.0")

Swift helpers to easier map things like .mapKeys, .mapKeysAndValues, .mapValuesUsingKeys

Examples

.mapKeys

letnewDictionary=["a":1,"b":2].mapKeys{ $0.uppercased()}print(newDictionary) // ["A": 1, "B": 2]

.mapValuesUsingKeys

letnewDictionary=["a":1,"b":2].mapValuesUsingKeys{ value, key inreturn"\(key)\(value)"}print(newDictionary) // ["a": "a1", "b": "b2"]

.mapKeysAndValues

letnewDictionary=["a":"x","b":"y"].mapKeysAndValues{ key, value inreturn(key.uppercased(), value.uppercased())}print(newDictionary) // ["A": "X", "B": "Y"]

Documentation

See the documentation for more info.

Releases

Packages

Used by

Contributors

Languages