Sobes.tech
Junior — Middle

Is it permissible to call private methods inside extension functions?

sobes.tech AI

Answer from AI

In Kotlin, extension functions do not have access to the private methods or properties of the class they are extending because they are not members of that class, but merely syntactic sugar for calling static methods.

That is, within an extension function, you can only access public and protected members of the class, but not private ones. If you need to work with private methods, it is better to implement the function inside the class itself.

Is it permissible to call private methods inside… - sobes.tech