# with() (scope function)

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

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

Author: author@typealias.com (Dave Leeds)

Published: 2017-09-14T01:00:44Z

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>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [guide](<https://devfeed.tech/tags/guide.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-standard-library](<https://devfeed.tech/tags/kotlin-standard-library.md>), [programming](<https://devfeed.tech/tags/programming.md>), [receiver](<https://devfeed.tech/tags/receiver.md>), [scope-function](<https://devfeed.tech/tags/scope-function.md>), [scope-functions](<https://devfeed.tech/tags/scope-functions.md>), [with](<https://devfeed.tech/tags/with.md>)

## AI overview

An overview of Kotlin's with() scope function, including how it accepts a receiver as an argument, makes that receiver available inside a code block, and returns the block's result. It also covers an initialization-and-execution use case and compares with() with related scope functions.

## Source excerpt

Overview The with() function is a scope function found in the Kotlin standard library. Unlike let(), also(), run() with receiver, and apply(), with() is not an extension function, but instead accepts the receiver as an argument. Example val size = with("Hello") { println(this) length } In this example, the string "Hello" is printed, and then its length is assigned to the size variable. Characteristics When the with() extension function executes: