I do not know if here is the best place to ask about kotlin and swift.
So, I have been searching about the differences between Kotlin and Swift. And, I did not understand what extensions in Swift can do that in Kotlin you couldn’t do and vice-versa.
I know that in kotlin, extensions are static functions that receive the called class as parameter. But, what makes it different from swift? In swift, can we access private fields of the class using extensions and in kotlin we cannot ?
Sorry so my language. And, thanks for your response!
When I said helper I meant this:
We would like to emphasize that extension functions are dispatched statically , i.e. they are not virtual by receiver type. This means that the extension function being called is determined by the type of the expression on which the function is invoked, not by the type of the result of evaluating that expression at runtime. https://kotlinlang.org/docs/reference/extensions.html
Kotlin extensions are like static methods on Java.
On the other hand, in swift:
Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you do not have access to the original source code (known as retroactive modeling ). Extensions are similar to categories in Objective-C. (Unlike Objective-C categories, Swift extensions do not have names.)
It seems that in swift the new methods or new properties are added to the class, structure, etc.