arraytoDictionary
-
Dictionary init(uniqueKeysWithValues:)Swift 2023. 1. 6. 12:26
Dictionary를 간단하게 설명하자면 요소들이 순서 없이 key와 value로 구성되는 collection Type이다. Dictionary는 key값이 유일해야하며, 같은 이름을 중복으로 사용할 수 없고 value는 상관없다. let dict: [String: Int] = ["A": 1, "B": 2, "C": 3] Dictionary init(uniqueKeysWithValues)는 주어진 시퀀스의 key-value 쌍에서 새로운 딕셔너리를 만든다. 간단히 말하면 배열에 value를 임의로 추가하여 새 Dictionary로 초기화시킨다고 알면된다. init(uniqueKeysWithValues keysAndValues: S) where S : Sequence, S.Element == (Key, V..