Skip to content

Instantly share code, notes, and snippets.

@mwrites
Last active July 22, 2017 06:32
Show Gist options
  • Save mwrites/f382a6f7a7fe6af3a77f22ec5c247b11 to your computer and use it in GitHub Desktop.
Save mwrites/f382a6f7a7fe6af3a77f22ec5c247b11 to your computer and use it in GitHub Desktop.
extend array of custom type
extension Array where Element:PackProtocol {
static func build(from json: [String:Any]) -> PackList {
let jsonPacks = json["packs"] as! [[String:Any]]
let packs = jsonPacks.flatMap { Pack.init(from: $0) }
return packs
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment