Bird
0
0

Why does Swift not allow implicit conversion between numeric types like Int and Double?

hard📝 Conceptual Q10 of 15
Swift - Data Types
Why does Swift not allow implicit conversion between numeric types like Int and Double?
ATo make code shorter and simpler
BTo prevent silent data loss and maintain type safety
CBecause Swift does not support numeric types
DBecause implicit conversion is slower at runtime
Step-by-Step Solution
Solution:
  1. Step 1: Understand Swift's design goals

    Swift prioritizes safety and clarity to avoid bugs.
  2. Step 2: Reason about implicit conversions

    Implicit conversions can cause unexpected data loss or errors, so Swift disallows them.
  3. Final Answer:

    To prevent silent data loss and maintain type safety -> Option B
  4. Quick Check:

    Implicit conversion disallowed for safety [OK]
Quick Trick: Swift disallows implicit conversions to keep code safe [OK]
Common Mistakes:
  • Thinking implicit conversions improve performance
  • Believing Swift lacks numeric types
  • Assuming implicit conversions make code simpler

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes