Dictionaries in Swift
Published in
1 min readApr 8, 2017
As you may know in Swift arrays to read out a value, you can call it’s index value like so:
Instead of needing to remember the index value that is assigned to each value we can re-write this with a dictionary.
With dictionaries, instead of arbitrary numbers you have read and write values using a key you specify.
Let’s create a simple organized dictionary:
You can read into a dictionary like so:
You can see with dictionaries, you create it by writing it’s key, then a colon, then it’s value.
You can read any value from the dictionary you create by knowing the key.
Must easier to work with than remembering an index number don’t you think?