Actions

Difference between revisions of "Kotlin"

From zen2

(Created page with "==Class== By default Kotlin classes are final, meaning no classes can inherit from them. In order to make them not final declare them open <pre> open class Vehicle() {} </pre>")
 
Line 3: Line 3:
 
<pre>
 
<pre>
 
open class Vehicle() {}
 
open class Vehicle() {}
 +
</pre>
 +
To override class functions they must also be declared open
 +
<pre>
 +
open class Vehicle() {
 +
    open fun drive() {}
 +
}
 
</pre>
 
</pre>

Revision as of 01:01, 18 November 2017

Class

By default Kotlin classes are final, meaning no classes can inherit from them. In order to make them not final declare them open

open class Vehicle() {}

To override class functions they must also be declared open

open class Vehicle() {
    open fun drive() {} 
}