0PricingLogin
Kotlin Multiplatform Academy · Lesson

Business Rules as Pure Functions

Keep logic testable by avoiding platform side effects.

What Is a Pure Function

A pure function returns the same output for the same input and touches nothing outside itself. That makes it perfect for shared code.

No Hidden Side Effects

Pure means no logging, no network, no saving to disk. The function just takes values in and gives a result back.

fun shippingFee(weight: Double): Double = if (weight > 5) 9.0 else 4.0

All lessons in this course

  1. A Shared Price & Tax Calculator
  2. Format Currency & Numbers
  3. Business Rules as Pure Functions
  4. Keep UI Out of Shared Code
← Back to Kotlin Multiplatform Academy