Created
October 2, 2022 14:50
-
-
Save AhmedMenaim/9fe80e168158c5f3a3f46af4ebb6e8cf to your computer and use it in GitHub Desktop.
Menaim Academy - Swift Course - Collection Types - Dictionaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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