title: Swift enumerate functions. How does it work behind?
body: <blockquote>
    <p>The <strong>enumerate</strong> function returns a <strong>tuple</strong> for each item in the array composed of the index and the value for that item.</p>
    
    <p>The <strong>map</strong> function returns an <strong>array of elements</strong> built from the results of applying a provided transforming closure for each element in the array.</p>
    
    <p><strong>Declaration</strong>: </p>
  
  <pre><code>func map&lt;U&gt;(transform: (T) -&gt; U) -&gt; [U]
  </code></pre>
  </blockquote>
  
  <pre><code>var numbers = [1, 2, 3]
  numbers = map(numbers) { (index, element) in
      index + element
  } //[1, 3, 5]
  </code></pre>
  
  <p>That is good. Works. </p>
  
  <pre><code>var numbers = [1, 2, 3]
  var result = map(enumerate(numbers)) { (index, element) in
      index + element
  } //[1, 3, 5]
  </code></pre>
  
  <p><code>map</code> expects an array as a first parameter, but I put there the tuple <em>as a result of enumerate fnction</em>. </p>
  
  <p>The question is: <strong>WHY IT WORKS?</strong></p>