Kotlin Functions
Functions are concise in Kotlin and can be highly expressive. Default values and named arguments reduce overload noise.
Parameters
fun greet(name: String, title: String = "developer") {
println("$name is a $title")
}
Named arguments
Named arguments make call sites self-documenting and reduce ambiguity when a function accepts multiple values of similar type.
Lambdas
val sum = { a: Int, b: Int -> a + b }
Extension functions
Extension functions let you add behavior to existing types without subclassing or wrapper objects.
Practice
- Write one function with a default parameter.
- Call a function using named arguments.
- Create one small lambda and one extension function.