Which of the following best describes the purpose of tuples in Swift?
easy📝 Conceptual Q1 of 15
Swift - Data Types
Which of the following best describes the purpose of tuples in Swift?
ATo define a class with multiple properties
BTo group multiple values into a single compound value
CTo create a collection of elements of the same type
DTo declare a variable that can change type dynamically
Step-by-Step Solution
Solution:
Step 1: Understand tuples
Tuples group multiple values into one compound value without creating a custom type.
Step 2: Compare options
To group multiple values into a single compound value correctly describes tuples. Options B and C describe classes and arrays respectively, and D is incorrect in Swift.
Final Answer:
To group multiple values into a single compound value -> Option B
Quick Check:
Tuples group different values together [OK]
Quick Trick:Tuples combine multiple values into one [OK]
Common Mistakes:
Confusing tuples with arrays or classes
Thinking tuples can only hold same-type values
Master "Data Types" in Swift
9 interactive learning modes - each teaches the same concept differently