Learn
Dictionaries
Introduction to Dictionaries

Data often comes in pairs.

On our phones’ contact list, every name is associated with a phone number. When we go shopping for an item, it is marked with a price. Searching up a word in a dictionary will get us the definition.

In programming, paired data can be found in a dictionary.

A dictionary is an unordered collection of paired data. The paired data is commonly referred to as a key-value pair in which a key is a unique identifier for their associated value.

In our phones’ contact list, every entry is like a key-value pair. The name of the contact would be considered the key and their associated number would be the value.

In this lesson, we will learn how to create, manipulate, and use dictionaries in Swift.

Instructions

Take a look at the image to the right.

We have a collection of keys and chests. Each key is associated with a treasure chest of the same color. In the center, there is a locked red chest that is holding something valuable. We are only able to access the treasure when we use the associated red key to unlock it.

When you’re ready, click Next to learn how to create a dictionary.

Folder Icon

Take this course for free

Already have an account?