LoginSignup
5
2

More than 5 years have passed since last update.

Swift 3でDictionaryのキーだけの配列を作る

Last updated at Posted at 2017-01-03
var dictionary = [
    "key1": "value1",
    "key2": "value2"
]

print(dictionary.keys)

LazyMapCollection<Dictionary<String, String>, String>(_base: ["key2": "value2", "key1": "value1"], _transform: (Function)) とかいうの出てきた

[String]でイニシャライズすればいいっぽい

var keys = [String](dictionary.keys)
print(keys)

["key2", "key1"]

:tada: (※Dictionaryでは順番は保証されません)

参考

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2