Sobes.tech
Junior — Senior

Research on the operation of expanding functions

livecode

Task condition

Specify what output will be obtained when running the following code:

open class Animal

class Cat: Animal()

fun Animal.voice() = "???"

fun Cat.voice() = "meow"

fun doVoice(animal: Animal) {
    println(animal.voice())
}

fun main() {
    val animal = Animal()
    val cat = Cat()
    doVoice(animal)
    doVoice(cat)
}