Type Inference and Explicit Types
How Swift infers types and when to declare them explicitly.
Welcome
Swift is a *statically typed* language — every value has a type known at compile time. But you rarely need to write the type yourself because Swift infers it for you.
What is Type Inference?
Swift examines the value on the right-hand side and deduces the type automatically:
```swift
let message = "Hello" // inferred as String
let count = 42 // inferred as Int
let price = 9.99 // inferred as Double
```
No type annotation needed — the compiler figures it out.
All lessons in this course
- let vs var: Constants and Variables
- Type Inference and Explicit Types
- Numbers, Booleans and Characters
- String Fundamentals and Interpolation