Recall & Review
beginner
What does it mean that structs are value types in Swift?
It means when you assign a struct to a new variable or pass it to a function, Swift makes a copy of the struct instead of sharing the same instance.
Click to reveal answer
beginner
How does assigning one struct variable to another affect their data?
Each variable gets its own separate copy of the data. Changing one does not affect the other.
Click to reveal answer
intermediate
Compare structs and classes in Swift regarding assignment behavior.
Structs are value types and are copied on assignment. Classes are reference types and share the same instance when assigned.
Click to reveal answer
intermediate
Why might Swift use value types like structs for some data?
Value types help avoid unexpected changes because each copy is independent. This makes code safer and easier to understand.
Click to reveal answer
beginner
If you change a property of a struct after assigning it to another variable, what happens?
Only the struct you changed is affected. The other variable still has the original data because it has its own copy.
Click to reveal answer
What happens when you assign a Swift struct to a new variable?
✗ Incorrect
Structs are value types, so assignment creates a new copy.
If you modify a struct after assigning it to another variable, what happens to the other variable?
✗ Incorrect
Each struct variable holds its own copy, so changes do not affect others.
Which of these is a reference type in Swift?
✗ Incorrect
Classes are reference types; structs, enums, and tuples are value types.
Why are structs considered safer for some data than classes?
✗ Incorrect
Copying on assignment prevents unexpected changes from shared references.
Which keyword defines a struct in Swift?
✗ Incorrect
The keyword 'struct' is used to define a struct in Swift.
Explain in your own words what it means that structs are value types and how assignment works.
Think about what happens when you give a copy of a drawing to a friend.
You got /4 concepts.
Describe the difference between structs and classes in Swift regarding how they handle data when assigned to new variables.
Imagine copying a photo versus sharing a link to the photo.
You got /4 concepts.