Skip to content

Instantly share code, notes, and snippets.

@IanKeen
Created August 7, 2020 20:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanKeen/46c7ca24708a1a56c75d4f71299aaad5 to your computer and use it in GitHub Desktop.
Save IanKeen/46c7ca24708a1a56c75d4f71299aaad5 to your computer and use it in GitHub Desktop.
Quick and dirty way to get a keypath from Decodable error
extension Array where Element: CodingKey {
var keyPath: String {
return map { $0.intValue == nil ? $0.stringValue : "[\($0.intValue!)]" }
.joined(separator: ".")
.replacingOccurrences(of: ".[", with: "[")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment