Swift: declare an empty dictionary

var emptyDictionary = [String: String]()

var populatedDictionary = ["key1": "value1", "key2": "value2"]

Note: if you’re planning to change the contents of the dictionary over time then declare it as a variable (var). You can declare an empty dictionary as a constant (let) but it would be pointless if you have the intention of changing it because constant values can’t be changed after initialization.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)