Many ways of defining a Swift dictionary

后端 未结 2 968
时光说笑
时光说笑 2020-12-22 04:07

In swift there are quite a few ways on defining a dictionary. So, are all of these identical?

var dic1 = Dictionary()

var dic2 = [String:         


        
2条回答
  •  暖寄归人
    2020-12-22 04:46

    Yes, all these 6 lines do produce the same result:

    • an empty
    • mutable
    • dictionary
    • where the key has type String
    • and the value has type Int

提交回复
热议问题