Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created December 24, 2020 13:29
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 PatilShreyas/58a6c34af78e19c3f103f30fd8a3e871 to your computer and use it in GitHub Desktop.
Save PatilShreyas/58a6c34af78e19c3f103f30fd8a3e871 to your computer and use it in GitHub Desktop.
data class User(val id: Int, val name: String)
class Task(val id: Int, val title: String, var assignedUser: User? = null) {
infix fun assignTo(user: User) {
// Other validation checks
assignedUser = user
}
}
fun main() {
val user = User(10, "John Doe")
val task = Task(567, "Fix bug in the production")
task assignTo user
println("'${task.title}' assigned to ${task.assignedUser?.name}") // 'Fix bug in the production' assigned to John Doe
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment