fun class명.확장함수명()
class Test{
companion object{
val data1: Int = 10
fun myFun1(){
println("companion object myFun1()...")
}
}
}
val Test.Companion.data2: Int
get() = 20
fun Test.Companion.myFun2(){
println("extension myFun2()...")
}
fun main(args: Array<String>){
println("data1 : ${Test.data1}.. data2 : ${Test.data2}")
Test.myFun1()
Test.myFun2()
}
🖥
data1 : 10.. data2 : 20
companion object myFun1()...
extension myFun2()...