Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// a routine:
fun saveUserTasks(userId: Int) {
val user = loadUser(userId)
println("user loaded")
val tasks = loadTasks(user)
println("tasks loaded")
saveTasks(tasks)
}
// when called multiple times:
fun main() {
println("Call #1:")
saveUserTasks(7)
println("Call #2:")
saveUserTasks(7)
println("Call #3:")
saveUserTasks(7)
println("done!")
}
// its like calling it for the first time:
/*
Call #1:
loading a user...
user loaded
loading tasks for provided user...
tasks loaded
saving provided tasks...
Call #2:
loading a user...
user loaded
loading tasks for provided user...
tasks loaded
saving provided tasks...
Call #3:
loading a user...
user loaded
loading tasks for provided user...
tasks loaded
saving provided tasks...
done!
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment