1
1
Fork 0
AtomicKotlinCourse/Power Tools/Property Delegation Tools/Exercise 2/task.md

620 B

Property Delegation Tools (#2)

Create a generic function observe() that uses trace() to capture "$propertyName $oldValue to $newValue" whenever a property changes. Ensure that it works with:

class Product(nm: String = "<0>", id: Int = -1) {
  var name by observable(nm, ::observe)
  var ident by observable(id, ::observe)
  override fun toString() = "$name $ident"
}

And that the starter code in main() successfully executes.

This task doesn't contain automatic tests, so it's always marked as "Correct" when you run "Check". Please compare your solution with the one provided!