Using Expressions Instead of Statements
Explore how expressions differ from statements in Kotlin and understand why relying on expressions supports functional programming. Learn the benefits of pure functions, pattern matching with the when expression, and how Kotlin simplifies code by avoiding mutable state and verbose control structures.
We'll cover the following...
We'll cover the following...
A statement is a block of code that doesn’t return anything. An expression, on the other hand, returns a new value. Since statements produce no results, the only way for them to be useful is to mutate the state—whether that’s changing a variable, changing a data structure, or performing some kind of IO.
Functional ...