Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created October 28, 2018 13:38
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/0d0aed1accdfe692862571e48ac3875d to your computer and use it in GitHub Desktop.
Save le0nidas/0d0aed1accdfe692862571e48ac3875d to your computer and use it in GitHub Desktop.
fun LessUglyTask.printAssignment() {
when {
assignedGroup == null && assignedUser == null -> println("\"$name\" is assigned to no one")
assignedGroup != null -> println("\"$name\" is assigned to to group: ${assignedGroup.name}")
assignedUser != null -> println("\"$name\" is assigned to to user: ${assignedUser.name}")
}
}
val le0nidas = User("le0nidas")
val kotlinEnthusiasts = Group("kotlin enthusiasts")
LessUglyTask("buy milk").printAssignment()
LessUglyTask("write post", assignedUser = le0nidas).printAssignment()
LessUglyTask("write kotlin", assignedGroup = kotlinEnthusiasts).printAssignment()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment