Skip to content

Instantly share code, notes, and snippets.

@debreuil
Created June 12, 2014 03:09
Show Gist options
  • Save debreuil/a16d68b58ecf2bc8cf14 to your computer and use it in GitHub Desktop.
Save debreuil/a16d68b58ecf2bc8cf14 to your computer and use it in GitHub Desktop.
// How do you get the keys from a dictionary?
let array = [1,2,3]
let dict = [1: "One", 2: "Two", 3: "Three"]
// cast to get the keys in an array
var keys = Array(dict.keys)
keys == array // comapre arrays with ==
var values = Array(dict.values) // the same works for values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment