How can I merge two arrays into a dictionary?

前端 未结 6 1743
青春惊慌失措
青春惊慌失措 2020-12-16 14:39

I have 2 arrays:

    var identic = [String]()
    var linef = [String]()

I\'ve appended them with data. Now for usability purposes my goal

6条回答
  •  臣服心动
    2020-12-16 14:48

    This is a generic solution

    func dictionaryFromKeysAndValues(keys:[K], values:[V]) -> Dictionary
    {
      assert((count(keys) == count(values)), "number of elements odd")
      var result = Dictionary()
      for i in 0..

提交回复
热议问题