So, enough of this theory let’s see the example first of how we can use these conventions in our application. Similarly, the same technique applies on get, set, in, and on a rangeTo convention. Because of that Kotlin refers to this technique as Kotlin Conventions. What is Kotlin Conventions:įor Example, if your class defines a special method name plus, then, by convention you can use the + operator on the instance of this class. The set of interfaces implemented by a class is fixed, and Kotlin can’t modify an existing class so that it would implement additional interfaces. We all know, Kotlin use the principle of a convention, instead of relying on types of Java does, because this allows developers to adapt existing Java classes to the requirement of Kotlin language features.
0 Comments
Leave a Reply. |