title: Is there approach to map dictionary keys/values simultaneously in Swift?
body: <p>Referring to: <em>Swift Standard Library > Dictionary > <a href="https://developer.apple.com/reference/swift/dictionary/1689397-map" rel="nofollow noreferrer">map(_:)</a></em></p>
  
  <blockquote>
    <p>Returns <strong>an array</strong> containing the results of mapping the given closure
    over the sequence’s elements.</p>
  </blockquote>
  
  <p>As mentioned, we can do mapping in dictionaries, but the output will be <em>an array</em>, not a "mapped" dictionary.</p>
  
  <p>Honestly, I'm not pretty sure if saying "mapping the whole dictionary" is legal, but what I mean is the following:</p>
  
  <p>Consider that we have:</p>
  
  <pre><code>let myDict = ["1": "one","2": "tow","3": "three"]
  </code></pre>
  
  <p>and we want to map the whole thing! (both keys and values). Output should be:</p>
  
  <pre><code>let mappedDict = ["03": "THREE", "02": "TOW", "01": "ONE"]
  </code></pre>
  
  <p>Let's assume that the goal of the mapping is to add "0" as a first character to all keys and let all values to be upper-cased.</p>
  
  <p>To make it more readable, I posted a solution (what I tried) as an answer instead of mentioning it in the question it self; I think my answer is not so <em>elegant</em> (or at least how I feel about its code smell), I mapped the keys, the values and combine them in a dictionary, each step has been achieved independently.</p>
  
  <p>So, What I am asking about is:</p>
  
  <p>Is there a way to do this job directly in one step? Something similar to:</p>
  
  <p><em>This snippet is a demonstration of what I'm asking about, code won't work fine</em></p>
  
  <pre><code>let myDict = ["1": "one","2": "tow","3": "three"]
  let mappedDict = myDict.map { key, value in
      "0" + key
      value.uppercased()
  }
  </code></pre>
  
  <p>Thanks in advance.</p>