Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created February 22, 2021 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save le0nidas/b403cb1631c83a43b4cf3c7ebbca56ad to your computer and use it in GitHub Desktop.
Save le0nidas/b403cb1631c83a43b4cf3c7ebbca56ad to your computer and use it in GitHub Desktop.
fun saveUserTasks(userId: Int, state: Int) {
when (state) {
0 -> {
val user = loadUser(userId)
println("user loaded")
// save loaded user
// pause execution
}
1 -> {
// resume execution
// restore saved user
val tasks = loadTasks(user) // ERROR: unknown user
println("tasks loaded")
// save loaded tasks
// pause execution
}
2 -> {
// resume execution
// restore saved tasks
saveTasks(tasks) // ERROR: unknown tasks
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment