Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Last active December 24, 2020 11:24
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