<https://kotlinlang.org/docs/extensions.html> is ...
# compiler
a
https://kotlinlang.org/docs/extensions.html is this function passed by value, not by reference? if passed by value, how to passed by reference?
Extension functions are normal functions with the receiver being the first parameter.
a
so it is not like C++, TypeScript. What design consideration is this syntax?
c
For example, you can write new functions for a class or an interface from a third-party library that you can’t modify. Such functions can be called in the usual way, as if they were methods of the original class. This mechanism is called an extension function. There are also extension properties that let you define new properties for existing classes.
h
Wait, I talked about Java classs code representation.
a
why not inherit from the class or use design patterns such as Decorator? why is it better than these two ways? is you says Decorator concept equal to this Decorator ?
c
Because you might not have access do the class implementation. You totally misunderstand the concept of extensions.