Created
June 1, 2019 01:46
-
-
Save RinniSwift/2ab0018b8bf06e6f3fcf0fc62c948ecb to your computer and use it in GitHub Desktop.
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
var dict = ["blue": 2, "grey": 1, "red": 2] | |
// for-each loop | |
dict.forEach { pair in | |
print(pair) | |
} | |
// for-in loop | |
for pair in dict { | |
print(pair) | |
} | |
for (key, val) in dict { | |
print("key: \(key), value: \(val)") | |
} | |
for keys in dict.keys { | |
print(keys) | |
} | |
for values in dict.values { | |
print(values) | |
} | |
for (ind, pair) in dict.enumerated() { | |
print("index: \(ind), with pair: \(pair)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment