윤동환
02/13/2023, 4:55 AMclass HelloService : HelloContext {
fun execute() {
this.printName("apple")
}
}
interface HelloContext
fun HelloContext.printName(name: String) {
println("name = ${name}")
}
윤동환
02/13/2023, 4:57 AMJacob
02/13/2023, 5:40 AM윤동환
02/13/2023, 6:34 AMno this reference in the printName function
!! thank you jacob!윤동환
02/13/2023, 7:00 AMVampire
02/13/2023, 7:57 AM윤동환
02/13/2023, 8:04 AMTies
02/13/2023, 8:08 AMthis
and therefor it can also just be a function in it's own file. It doesn't have to be an extension function of anything, it can be a function without a class that you can also import in other places 🙂Vampire
02/13/2023, 8:46 AMHelloContext
.Jacob
02/13/2023, 1:06 PM윤동환
02/13/2023, 1:10 PM