This Android project demonstrates the use of Kotlin's scope functions (let
, also
, apply
, run
, with
) in an Android application.
The main activity of the application is MainActivity.kt
, which is located in the com.aviva.scopefunctions
package.
In MainActivity.kt
, each of the Kotlin scope functions is demonstrated:
letScopeExample()
: Demonstrates the use oflet
with a nullable variable.alsoScopeExample()
: Demonstrates the use ofalso
to perform a side effect operation.applyScopeExample()
: Demonstrates the use ofapply
to set multiple properties of anIntent
object.runScopeExample()
: Demonstrates the use ofrun
to execute a block of code on anIntent
object.withScopeExample()
: Demonstrates the use ofwith
to execute a block of code on anIntent
object.
To run the project, open it in Android Studio and run the MainActivity.kt
file.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.