title: Using map() to initialize array inline from array of Dictionary (i.e. a JSON array)
body: <p>My class can be initialized from a JSON Dictionary</p>
  
  <pre><code>class ChildObject {
      required init?(fromDictionary dictionary: [String:Any]) { //init... }
  }
  </code></pre>
  
  <p>And now I was given an array of such Dictionaries:</p>
  
  <pre><code>// objectDictionaries = [[String:Any]]
  </code></pre>
  
  <p>Now I want to initialize an array of my class inline using <code>map</code>. I'm initializing an array inside another class.</p>
  
  <pre><code> class ParentObject {
        var children: [ChildObject]
  
        required init?(fromDictionary aDictionary: [String:Any]) {
              guard let childDictionaries = aDictionary["children"] as? [[String:Any]],
                 let children = childDictionaries.map { ChildObject(fromDictionary: $0) }
                 else { return nil }
              self.children = children
        }
  
   }
  </code></pre>
  
  <p>But this doesn't compile--- can anyone tell me the correct syntax? I tried <code>forEach</code> but that also didn't work. </p>
  
  <p>In a playground I get</p>
  
  <ul>
  <li>Expected else after guard </li>
  <li>Anonymous closure argument not contained in a
  closure </li>
  <li>Expected Expression </li>
  <li>Braces block of statements in an unused
  closure</li>
  </ul>