MapSugar

0.1.4

🗺️ Swift helpers to easier map things like .mapKeys, .mapKeysAndValues, .mapValuesUsingKeys
mesqueeb/MapSugar

What's New

v0.1.4

2025-02-02T20:54:05Z

internal maintenance

this version doesn't have any external differences since v1.0.0

https://github.com/mesqueeb/MapSugar/compare/v0.1.0..v0.1.4

MapSugar 🗺️

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

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

Examples

.mapKeys

let newDictionary = ["a": 1, "b": 2]
  .mapKeys { $0.uppercased() }

print(newDictionary) // ["A": 1, "B": 2]

.mapValuesUsingKeys

let newDictionary = ["a": 1, "b": 2].mapValuesUsingKeys { value, key in
  return "\(key)\(value)"
}

print(newDictionary) // ["a": "a1", "b": "b2"]

.mapKeysAndValues

let newDictionary = ["a": "x", "b": "y"].mapKeysAndValues { key, value in
  return (key.uppercased(), value.uppercased())
}

print(newDictionary) // ["A": "X", "B": "Y"]

Documentation

See the documentation for more info.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri May 16 2025 15:01:47 GMT-0900 (Hawaii-Aleutian Daylight Time)