# First-Class Function

DevFeed: [First-Class Function](<https://devfeed.tech/articles/first-class-function-25013.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/first-class-function/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-09-01T00:00:00Z

Content type: tutorial

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming language](<https://devfeed.tech/topics/programming-language.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [argument](<https://devfeed.tech/tags/argument.md>), [class](<https://devfeed.tech/tags/class.md>), [examples](<https://devfeed.tech/tags/examples.md>), [function](<https://devfeed.tech/tags/function.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [reference](<https://devfeed.tech/tags/reference.md>)

## AI overview

This article explains first-class functions in Kotlin. It covers assigning functions to variables, passing functions as arguments, and returning functions as results, with examples using anonymous functions, lambdas, and function references.

## Source excerpt

A programming language that supports first-class functions allows you to: Assign a function to a variable Pass a function to another function as an argument Return a function from another function as a result Kotlin allows you to do all three of these. Assigning Functions There are a few different ways that you can assign a function to a variable in Kotlin. Anonymous Function val add = fun(a: Int, b: Int) = a + b Lambda val subtract = { a: Int, b: Int -> a - b } Function Reference If the method already exists, you can assign it by means of a function reference