title: Convert Swift Array to Dictionary with indexes
body: <p>I'm using Xcode 6.4</p>
  
  <p>I have an array of UIViews and I want to convert to a Dictionary with keys <code>"v0", "v1"...</code>. Like so:</p>
  
  <pre><code>var dict = [String:UIView]()
  for (index, view) in enumerate(views) {
    dict["v\(index)"] = view
  }
  dict //=&gt; ["v0": &lt;view0&gt;, "v1": &lt;view1&gt; ...]
  </code></pre>
  
  <p>This works, but I'm trying to do this in a more functional style. I guess it bothers me that I have to create the <code>dict</code> variable. I would love to use <code>enumerate()</code> and <code>reduce()</code> like so:</p>
  
  <pre><code>reduce(enumerate(views), [String:UIView]()) { dict, enumeration in
    dict["v\(enumeration.index)"] = enumeration.element // &lt;- error here
    return dict
  }
  </code></pre>
  
  <p>This feels nicer, but I'm getting the error: <code>Cannot assign a value of type 'UIView' to a value of type 'UIView?'</code> I have tried this with objects other an <code>UIView</code> (ie: <code>[String] -&gt; [String:String]</code>) and I get the same error.</p>
  
  <p>Any suggestions for cleaning this up?</p>