Recall & Review
beginner
What is an Array in Swift?
An Array is an ordered collection of values. You can access elements by their position (index). Arrays keep the order of items.
Click to reveal answer
beginner
How does a Dictionary work in Swift?
A Dictionary stores key-value pairs. Each key is unique and maps to a value. You use the key to find the value quickly.
Click to reveal answer
beginner
What is a Set in Swift and when to use it?
A Set is an unordered collection of unique values. Use it when you want to store items without duplicates and order does not matter.
Click to reveal answer
beginner
How do you add an element to a Swift Array?
Use the append() method. For example: myArray.append(5) adds the number 5 to the end of the array.
Click to reveal answer
beginner
How do you check if a Set contains a value in Swift?
Use the contains() method. For example: mySet.contains(3) returns true if 3 is in the set, otherwise false.
Click to reveal answer
Which Swift collection type keeps elements in order and allows duplicates?
✗ Incorrect
Arrays keep elements in order and allow duplicates. Sets do not keep order and do not allow duplicates.
How do you access a value in a Dictionary?
✗ Incorrect
Dictionaries use keys to access their values, not index numbers.
What happens if you add a duplicate element to a Set?
✗ Incorrect
Sets ignore duplicates and keep only unique elements.
Which method adds an element to the end of an Array?
✗ Incorrect
The append() method adds an element to the end of an Array.
Which collection type is best to store unique items without caring about order?
✗ Incorrect
Set stores unique items and does not keep order.
Explain the differences between Array, Dictionary, and Set in Swift.
Think about order, uniqueness, and how you access elements.
You got /3 concepts.
Describe a real-life example where you would use a Set instead of an Array.
Imagine a guest list where each person should appear only once.
You got /3 concepts.