title: Append to array in [String: Any] dictionary structure
body: <p>Assembling a data payload passed to <a href="https://github.com/groue/GRMustache.swift">GRMustache.swift</a> for rendering mustache templates, I'm in a scenario where I need to append data to an array previously defined in the dictionary.</p>
  
  <p>My data structure starts off as:</p>
  
  <pre><code>var data: [String: Any] = [
      "key1": "example value 1",
      "key2": "example value 2",
      "items": [
          // I need to append here later
      ]
  ]
  </code></pre>
  
  <p>The <code>items</code> key pair is a collection I need to append later within a loop.</p>
  
  <p>To add to the <code>data["items"]</code> array, I'm trying something like:</p>
  
  <pre><code>for index in 1...3 {
      let item: [String: Any] = [
          "key": "new value"
      ]
  
      data["items"].append(item)
  }
  </code></pre>
  
  <p>This errors, as value of type <code>Any?</code> has no member <code>append</code>, and binary operator <code>+=</code> cannot be applied to operands of type <code>Any?</code> and <code>[String : Any]</code>.</p>
  
  <p>This makes sense, as I need to cast the value to append; however, I can't mutate the array.</p>
  
  <p>Casting to array, whether forcing downcast gives the error:</p>
  
  <pre><code>(data["items"] as! Array).append(item)
  </code></pre>
  
  <blockquote>
    <p>'Any?' is not convertible to 'Array&lt;_>'; did you mean to use 'as!' to force downcast?</p>
    
    <p>Cannot use mutating member on immutable value of type 'Array&lt;_>'</p>
  </blockquote>
  
  <p>Seems like my cast is wrong; or, perhaps I'm going about this in the wrong way.</p>
  
  <p>Any recommendation on how to fill <code>data["items"]</code> iteratively over time?</p>