Say you're decoding a huge JSON file:
struct Examp: Codable {
let Cats: [CatsItem]
let Dogs: [DogsItem]
let Horses: [HorsesItem]
.. forty more
}
After you parse it, on the console you simply want to see how many of each:
print("cats .. \(result.Cats.count)")
print("dogs .. \(result.Dogs.count)")
and so on, the result being cats 1,015, dogs 932, etc.
I'm too lazy to repeatedly type a line of code like this:
print("cats .. \(result.Cats.count)")
Without having to modify Examp in any way, is there a way to do something like:
for (thing) in Examp { print("\(thing string) .. \(result.(thing).count)") }