Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlinclass delegation bySingle-choice MCQ

A class delegates an interface to a `var` property, then that property is reassigned. Which method does the delegated call forward to?

interface Sink { fun write(s: String) } class FileSink(val name: String) : Sink { override fun write(s: String) = println("$name<-$s") } class Logger(var sink: Sink) : Sink by sink fun main() { val log = Logger(FileSink("A")) log.sink = FileSink("B") log.write("hi") }