This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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