0Pricing
Kotlin Academy · Lesson

expect and actual

Platform-specific implementations.

The Need for Platform Code

Some functionality has no common implementation — getting the OS name, a UUID, or the current platform. KMM solves this with the expect/actual mechanism.

expect Declarations

In commonMain you declare an expect function or class — a contract with no body. Common code can call it.

// commonMain
expect fun platformName(): String

All lessons in this course

  1. KMM Project Structure
  2. expect and actual
  3. Sharing Business Logic
  4. Platform APIs
← Back to Kotlin Academy