0Pricing
Swift Academy · Lesson

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

  1. let vs var: Constants and Variables
  2. Type Inference and Explicit Types
  3. Numbers, Booleans and Characters
  4. String Fundamentals and Interpolation
← Back to Swift Academy