A function type describes a callable value by its parameter types and return type. In Kotlin, it lets a variable, parameter, or return value hold a lambda or function reference, making behavior a value that can be passed, stored, and selected like other values. section 10.1.1 section 10.4
Declare and call a function value
```kotlin val sum: (Int, Int) -> Int = { x, y -> x + y } val action: () -> Unit = { println(42) } fun twoAndThree(operation: (Int, Int) -> Int) { println(operation(2, 3)) } twoAndThree { a, b -> a * b } // 6 ``` `(Int, Int) -> Int` means two `Int` inputs and an `Int` result. `() -> Unit` takes no arguments and has no meaningful result. Once a parameter has a function type, Kotlin can infer the lambda parameter types; call the passed function with ordinary call syntax, such as `operation(2, 3)`. section 10.1.1 section 10.1.2
Nullability placement matters. `(Int, Int) -> Int?` describes a function that may return `null`; `((Int, Int) -> Int)?` describes a value that may itself be `null`. Function-type declarations require an explicit return type, including `Unit`. Parameter names may be included for readability and IDE completion, but they do not affect type matching. section 10.1.1 section 10.1.2
Listing 10.1 Defining a simple higher-order function
fun twoAndThree(operation: (Int, Int) -> Int) { #1
val result = operation(2, 3) #2
println("The result is $result")
}
fun main() {
twoAndThree { a, b -> a + b }
// The result is 5
twoAndThree { a, b -> a * b }
// The result is 6
}
Use a function-typed parameter to make one operation reusable with multiple lambda implementations. section 10.1.2
Function types underpin higher-order functions: functions can accept behavior as a parameter or return behavior chosen for a condition. A shipping calculator can return `(Order) -> Double`, while a contact filter can return `(Person) -> Boolean` for later use with `filter`. section 10.1 section 10.1.5
This is especially useful when repeated code differs in behavior rather than only data. Instead of hardcoding several site-visit queries, accept a `(SiteVisit) -> Boolean` predicate; callers can supply conditions for mobile visits or iOS signup visits. The same approach can replace interface-heavy variants of the strategy pattern with lambdas. section 10.1.6
Kotlin’s standard `filter`, `map`, and `sortedBy` APIs demonstrate the style: function types work with lambdas and member references to express collection-processing pipelines concisely. They support functional programming alongside ordinary mutable, object-oriented code. section 1.2.3



