Skip to content

Commit

Permalink
KTLN-893: code sample
Browse files Browse the repository at this point in the history
  • Loading branch information
etrandafir93 committed Oct 22, 2024
1 parent 25bf59c commit 11fb7d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ fun main() {

println(task.toString())

val secondTask = Task(1002, 2)
println(secondTask.id) // 1002
println(secondTask.description) // Anonymous task with priority 2

val copyTask = task.copy(priority = 4)
println(copyTask.toString())

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.baeldung.dataclass

data class Task(var id: Int, var description: String, var priority: Int)
data class Task(var id: Int, var description: String, var priority: Int) {
constructor(id: Int, priority: Int) : this(id, "anonymous task with priority $priority", priority)
}

0 comments on commit 11fb7d0

Please sign in to comment.