Skip to content

Instantly share code, notes, and snippets.

@AkshayChordiya
Last active May 25, 2024 16:29
Show Gist options
  • Save AkshayChordiya/27c043efe6e15a0d03981141f99642a6 to your computer and use it in GitHub Desktop.
Save AkshayChordiya/27c043efe6e15a0d03981141f99642a6 to your computer and use it in GitHub Desktop.
Example of apply function in Kotlin
val person = Person().apply {
name = "Tony Stark"
age = 52
// More such stuff
}
@deggers
Copy link

deggers commented Nov 25, 2020

Do you still prefer this over named constructors with default values?
I initally liked this builder pattern as well, but type completion in IntelliJ is so slow for me. Especially when i have nested builder,
it takes literally seconds to show me the suggestions.. Is this not a problem for you ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment