Edited at

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

More than 1 year has passed since last update.

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では順番は保証されません)

参考

http://stackoverflow.com/questions/32242876/array-is-unavailable-please-construct-an-array-from-your-lazy-sequence-array