How to create empty dictionary in swift?

0 votes
117 views
asked Mar 3, 2015 in Swift by arthi (1,110 points)
Hi All

  How to create empty dictionary in swift?

1 Answer

0 votes
answered Mar 3, 2015 by codeg (2,600 points)

Hi Arthi

 

As with arrays, you can create an empty Dictionary of a certain type by using initializer syntax:

var namesOfIntegers = [Int: String]()

  • // namesOfIntegers is an empty [Int: String] dictionary
...