Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created December 24, 2020 13:29
Embed
What would you like to do?
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