I thought going back through all of these base features of Swift would be a bore, but it was quite fun. And despite this being the
nth time I was going over this stuff, I still learned a few new things.
First, I didn’t realize that if you want an initialize an array of type
Any, you can’t depend on type inference. Swift won’t infer an Array type if the initial values don’t have a class, parent class, struct, or protocol in common.
Also, I didn’t realize that you could define and initialize an Array using the syntax below. I guess if you explicitly specify the type in the definition, you don’t need to specify a type in the initialization part of the statement.
var powers: [String] =  powers.append("Super strength")
This made me wonder if dictionaries in Swift allowed a similar initialization syntax. Turns out they do.
var thingsICanSmell: [String: Bool] = [:] thingsICanSmell["coffee"] = true thingsICanSmell["dog poop"] = true thingsICanSmell["iocane powder"] = false