Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AhmedMenaim/9fe80e168158c5f3a3f46af4ebb6e8cf to your computer and use it in GitHub Desktop.
Save AhmedMenaim/9fe80e168158c5f3a3f46af4ebb6e8cf to your computer and use it in GitHub Desktop.
Menaim Academy - Swift Course - Collection Types - Dictionaries
import Foundation
// MARK: - What is the dictionary !?
// [Key -> Unique : Value] => Key is int , Value is String, Unsorted (Unarranged)
// MARK: - Creating a Dictionary
var dict: [Int : String] = [:]
var newDict = [12893483 : "Ahmed Menaim", 13713621: "Menaim"]
print(newDict)
// MARK: - Accessing and Modifying a Dictionary
newDict.count
newDict.isEmpty
dict.isEmpty // if dict is empty -> True, False
newDict[12893483] = "Ahmed Menaim Ezzat"
newDict[1238473922] = "New Baby"
print(newDict)
newDict.keys
newDict.values
newDict[1238473922] = nil
print(newDict)
// MARK: - Iterating Over a Dictionary => Loops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment