juniorKotlin
What is a Kotlin function?
Updated May 16, 2026
Short answer
A function is a reusable block of code defined using fun.
Deep explanation
Functions in Kotlin can take parameters, return values, and support default arguments and expression bodies.
Real-world example
Used for reusable logic like calculating totals in apps.
Common mistakes
- Forgetting return type in complex functions.
Follow-up questions
- What are default arguments?
- What is an expression body?