...

/

Extension Functions and Object Declarations

Extension Functions and Object Declarations

Learn how to define extension functions on object declarations, companion objects, and inside classes.

We'll cover the following...

Extension functions on object declarations

We can define extensions on object declarations.

Kotlin 1.5
object A
fun A.foo() {
print("\n Hi")
}
fun main() {
A.foo()
val a: A = A
a.foo()
}

Extension

...