Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/1-Old.kt Secret

Created Dec 24, 2020
Embed
What would you like to do?
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)
}
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