Bird
0
0

Identify the error in this code:

medium📝 Debug Q6 of 15
Swift - Data Types
Identify the error in this code:
typealias Number = Int
let value: Number = "100"
AVariable name 'value' is invalid
Btypealias syntax is wrong
CCannot assign String to Int alias
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check typealias and assignment

    Number is an alias for Int, but the value assigned is a String.
  2. Step 2: Understand type mismatch error

    Assigning a string to an integer type causes a compile-time error.
  3. Final Answer:

    Cannot assign String to Int alias -> Option C
  4. Quick Check:

    Type mismatch error = assigning wrong type [OK]
Quick Trick: Alias type must match assigned value type [OK]
Common Mistakes:
  • Ignoring type mismatch
  • Thinking alias changes underlying type
  • Assuming variable name causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes