Last active
May 25, 2024 16:29
-
-
Save AkshayChordiya/27c043efe6e15a0d03981141f99642a6 to your computer and use it in GitHub Desktop.
Example of apply function in Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val person = Person().apply { | |
name = "Tony Stark" | |
age = 52 | |
// More such stuff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ?