Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of `external` keyword in Kotlin?

What exactly is the purpose of the external keyword in Kotlin?

I guess it's for JNI like native in Java, but I can't seem to find any actual reference or documentation on this.

like image 752
maciekjanusz Avatar asked Feb 22 '16 11:02

maciekjanusz


People also ask

What is the use of internal keyword in Kotlin?

The internal visibility modifier means that the member is visible within the same module.

What is the use of open keyword in Kotlin?

Now we can extend the Try class. If we need to extend the Success class, we should mark it with the open keyword also. Therefore, the open keyword doesn't have a transitive effect on the classes. When we don't mark classes with the open keyword, then the Kotlin compiler emits a final class at the bytecode level.

What is difference between internal and private in Kotlin?

internal is an alternative to Java's package-private. internal means that the declarations are visible inside a module. internal provides real encapsulation for the implementation details, while in Java's package-private encapsulation could be broken.

What is this keyword in Kotlin?

In Kotlin, the “this” keyword allows us to refer to the instance of a class whose function we happen to be running.


1 Answers

Indeed, it's an equivalent of Java's native. It's currently missing from the documentation but there's an issue to add it.

like image 57
yole Avatar answered Sep 18 '22 18:09

yole