# also() (scope function)

DevFeed: [also() (scope function)](<https://devfeed.tech/articles/also-scope-function-25007.md>)

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

Author: author@typealias.com (Dave Leeds)

Published: 2017-09-04T19:41:30Z

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>)

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

## AI overview

A Kotlin tutorial explaining the also() scope function. It shows that also() exposes the receiver as the lambda argument, conventionally named it, and returns the receiver object.

## Source excerpt

Overview The also() function is a scope function that was introduced in Kotlin 1.1. Example val size = "Hello".also { println(it) }.length In this example, the string "Hello" is printed, and then its length is assigned to the size variable. Characteristics When the also() extension function executes: the receiver object that .also() is called upon is available as the lambda argument - by default, named it the result will be the receiver object Create, Pass, and Evaluate A prime use case for also() is the pattern where you need to pass an empty object to another function for initialization.