Swift’s type system is strict and expressive—numeric types, strings, booleans, and custom structs/enums all participate in compile-time checking with type inference.
Basic types
Int,Double,Float,Bool— numbers and logicString— Unicode text (value semantics with copy-on-write optimization)Character— single extended grapheme cluster- Integer sizes:
Int8,UInt, etc., when you need explicit width
Type safety
let a: Int = 10
let b: Double = 10.0
// let sum = a + b // compile error — must convert explicitly
Unlike JavaScript, Swift will not silently coerce incompatible numeric types.
Important interview questions and answers
- Q: Int vs Int32?
A:Intmatches the platform word size (64-bit on modern Apple devices); use sized integers for binary protocols and interop. - Q: Is Swift dynamically typed?
A: No—types are checked at compile time, with inference reducing annotation noise.
Self-check
- Can you add
IntandDoublewithout conversion? - What type does
truehave?
Tip: Swift will not silently add Int and Double—convert explicitly like in strict typed languages.
Interview prep
- Int vs Double addition?
Must convert explicitly—no silent numeric coercion.
- Dynamic typing?
No—Swift is statically typed with inference.