Bird
0
0

What is true about a Set in Swift?

easy📝 Conceptual Q11 of 15
Swift - Collections
What is true about a Set in Swift?
AIt can only store numbers, not strings.
BIt stores duplicate values in the order they were added.
CIt stores unique values without any specific order.
DIt always keeps elements sorted alphabetically.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Set properties

    A Set in Swift stores unique values and does not keep any order.
  2. Step 2: Compare options with Set behavior

    It stores unique values without any specific order. matches the unique and unordered nature of Sets. Others describe arrays or sorted collections.
  3. Final Answer:

    It stores unique values without any specific order. -> Option C
  4. Quick Check:

    Set = unique + unordered [OK]
Quick Trick: Remember: Sets never keep duplicates or order [OK]
Common Mistakes:
  • Thinking Sets keep order like arrays
  • Assuming Sets allow duplicates
  • Believing Sets only store numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes