June 2018
Intermediate to advanced
316 pages
6h 34m
English
A pure function doesn't have any side effects, like input/output operations, and doesn't depend on a variable that doesn't belong to a scope of this function. This means that the return value of this function only depends on parameters that are passed to it. For instance, the Kotlin standard library has a special package called kotlin.math that contains mathematical functions and constants:
import kotlin.math.*fun main(vars: Array<String>) { val minResult = min(3, 4)s val sqrtResult = sqrt(9.0)}
This package was developed especially to support multiple platforms. Under the hood, these methods invoke other methods depending on the platform. If your program runs in the JVM, it calls static functions from the java.lang.Math
Read now
Unlock full access