Skip to content

Instantly share code, notes, and snippets.

Created April 26, 2020 11:16
What would you like to do?
class Task(
val description: String,
val assignedTo: AssignedTo
sealed class AssignedTo(val name: String) {
object Nobody : AssignedTo("")
class User(name: String) : AssignedTo(name)
fun main() {
val buyMilk = Task("Buy milk", AssignedTo.Nobody)
val writePost = Task("Write post", AssignedTo.User("le0nidas"))
print(buyMilk, writePost)
// Task 'Buy milk' is assigned to
// Task 'Write post' is assigned to le0nidas
private fun print(vararg tasks: Task) {
tasks.forEach { task ->
println("Task '${task.description}' is assigned to ${}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment