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 Sprint(val todoTasks: Int, val doneTasks: Int) | |
fun main() { | |
val sprint1 = Sprint(51, 20) | |
val sprint2 = Sprint(30, 40) | |
val totalTodoTasks = sprint1.todoTasks + sprint2.todoTasks // 51 + 30 | |
val totalDoneTasks = sprint1.doneTasks + sprint2.doneTasks // 20 + 40 | |
val newSprint = Sprint(totalTodoTasks, totalDoneTasks) | |
} |
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 Sprint(val todoTasks: Int, val doneTasks: Int) { | |
operator fun plus(other: Sprint): Sprint { | |
return Sprint(todoTasks + other.todoTasks, doneTasks + other.doneTasks) | |
} | |
} | |
fun main() { | |
val sprint1 = Sprint(51, 20) | |
val sprint2 = Sprint(30, 40) | |
val newSprint = sprint1 + sprint2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment