Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/ScopesFun.kt Secret

Last active Dec 24, 2020
Embed
What would you like to do?
fun doSomething() {
// also {}
val users = userRepository.getAllUsers().also { println("All users: $it") }
// run {}
users.run {
val adminUsers = filter { it.isAdmin }
val totalCount = count()
}
// with()
with(users) {
val firstUser = first()
val lastUser = last()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment