# Function Reference

Published articles for Function Reference.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Lambdas and Function References

DevFeed: [Lambdas and Function References](<https://devfeed.tech/articles/lambdas-and-function-references-25059.md>)

Original publisher: [Read original article](<https://typealias.com/start/kotlin-lambdas/>)

Author: author@typealias.com (Dave Leeds)

Published: 2022-02-28T00: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>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [closure](<https://devfeed.tech/tags/closure.md>), [code](<https://devfeed.tech/tags/code.md>), [function](<https://devfeed.tech/tags/function.md>), [function-reference](<https://devfeed.tech/tags/function-reference.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [learn-to-program](<https://devfeed.tech/tags/learn-to-program.md>), [programming](<https://devfeed.tech/tags/programming.md>), [types](<https://devfeed.tech/tags/types.md>)

### AI overview

A tutorial introduction to Kotlin lambdas, function types, and function references, using a barber-shop pricing example involving coupons and tax.

### Source excerpt

As we've seen, functions are a basic building block of Kotlin code. Throughout this book, we've written a lot of them, all using the fun keyword. Kotlin also gives us another way to write functions--lambdas! To help us learn about function types, function references, and lambdas, we'll need to pay a visit to Bert's Snips & Clips. Bert's Snips & Clips Bert's Snips & Clips is the barber shop to go to for a clean haircut and a nice smooth shave.

## Kotlin Functional Interfaces: Function reference and SAM conversion

DevFeed: [Kotlin Functional Interfaces: Function reference and SAM conversion](<https://devfeed.tech/articles/kotlin-functional-interfaces-function-reference-and-sam-conversion-38640.md>)

Original publisher: [Read original article](<https://krossovochkin.com/posts/2020_10_17_kotlin_functional_interfaces_function_references_and_sam_conversion/>)

Published: 2020-10-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [Vasya Drobushkov](<https://devfeed.tech/sources/vasya-drobushkov.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [callback](<https://devfeed.tech/topics/callback.md>), [interface](<https://devfeed.tech/topics/interface.md>), [function](<https://devfeed.tech/topics/function.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [bytecode](<https://devfeed.tech/tags/bytecode.md>), [callback](<https://devfeed.tech/tags/callback.md>), [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [function](<https://devfeed.tech/tags/function.md>), [function-reference](<https://devfeed.tech/tags/function-reference.md>), [functional](<https://devfeed.tech/tags/functional.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [interop](<https://devfeed.tech/tags/interop.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>)

### AI overview

This tutorial examines Kotlin functional interfaces, function references, and SAM conversion in a callback scenario. It explains that Kotlin 1.4 supports SAM conversion for functional interfaces, allowing callback objects to be created from function references. Although separate callback objects are created for different method calls, they delegate to the same function reference and the program behaves correctly; explicit callback instances can avoid repeated allocations.

### Source excerpt

Introduction About two years ago I made a post about a tricky case in Kotlin-Java interop related to the usage of function references and SAM conversion. One of the points there was that in Kotlin, if interface is declared instead of a function, one has to explicitly create an object, therefore no caveats as with interop: val callback = object : ThirdParty.Callback { override fun onValueChanged(value: Int) { this@App.onValueChanged(value) } } With Kotlin 1.4 there is now a "Functional interface" which supports SAM conversion. And I've been asked on how it works in a similar situation. Let's find out.

## Function Reference

DevFeed: [Function Reference](<https://devfeed.tech/articles/function-reference-25014.md>)

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

Author: author@typealias.com (Dave Leeds)

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

Content type: article

Language: en

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

Topics: [function](<https://devfeed.tech/topics/function.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [Variable](<https://devfeed.tech/topics/variable.md>), [Closure](<https://devfeed.tech/topics/closure.md>)

Tags: [function](<https://devfeed.tech/tags/function.md>), [function-reference](<https://devfeed.tech/tags/function-reference.md>), [functions](<https://devfeed.tech/tags/functions.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>)

### AI overview

Kotlin function references let you store, pass, or return existing functions, alongside lambdas. A bound reference captures an object instance; an unbound member reference requires the instance when invoked, increasing the reference's argument count. Top-level and local function references need no receiver. A bound reference's receiver can be any expression, which is evaluated when the reference is created. The excerpt notes that bound references were introduced in Kotlin 1.1 and that lambdas are a typical choice for small functions used in one place; its alternatives discussion is cut off.

### Source excerpt

Overview Kotlin supports the notion of first-class functions - functions can be saved to variables, passed into functions, and returned from functions. When you need to do this, you can create lambdas - function literals - or you can refer to an existing function by means of a function reference. Usage Assigning a function: class Example { fun add(a: Int, b: Int) = a + b val operation = this::add } Passing a function: