Traversing the dictionary

var emojiMeaning = [
  "🤔": "Thinking Face",
  "😪": "Sleepy Face",
  "😵": "Dizzy Face"
]
// loop through keys and values
for (emoji, meaning) in emojiMeaning {
  print("\(emoji) is called '\(meaning)Emoji'")
}
// iterate through keys only
for emoji in emojiMeaning. keys {
  print(emoji)
}
// iterate through values only
for meaning in emojiMeaning. values {
  print(meaning)
}
Comments