I can define extension functions inside a class to...
# getting-started
j
I can define extension functions inside a class to limit this function to the context of an instance of this class like in the following example:
Copy code
object A {
    val string : String = "hallo"
    fun String.doSomething() { }
}

fun test() {
    with(A) {
        string.doSomething()
    }
}
Is there any way of adding such an extension function to a class when I cant modify it? Kind of like in the following pseudo-code:
Copy code
object A {
    val string : String = "hallo"
}

fun A.String.doSomething() { }