Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/ApplyKt.kt.diff Secret

Last active Dec 24, 2020
Embed
What would you like to do?
fun getUser(): User {
val user = User()
- user.isAdmin = true
- user.firstName = "John"
- user.lastName = "Doe"
- user.roles = listOf("Role1", "Role2")
- return user
+ return user.apply {
+ isAdmin = true
+ firstName = "John"
+ lastName = "Doe"
+ roles = listOf("Role1", "Role2")
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment