Choosing the Right Scope Function: Decision Guide
Select the correct scope function based on receiver, return type, and intent.
Five Functions, Two Axes
Kotlin's scope functions vary on two axes: receiver style (this or it) and return value (receiver or lambda result). Pick based on intent.
The Decision Matrix
apply: this / receiver. also: it / receiver. run: this / lambda. let: it / lambda. with: this / lambda (no receiver via dot).
All lessons in this course
- apply and with: Configure and Return
- let and run: Transform and Scope
- also: Side Effects Without Changing the Receiver
- Choosing the Right Scope Function: Decision Guide