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

646 B

Property Delegation (#2)

Start with:

class Delegator {
  private var list = List(8) { "$it" }
  var strings by list
}

Define getValue() and setValue() as extension functions to List<String> (Hint: IntelliJ IDEA will generate skeletons for you). The code in main() tests your solution.

BONUS: Try adjusting getValue() and setValue() to work with:

class Delegator {
  var strings by List(8) { "$it" }
  ...

And explain what happens.

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!