Kotlin basics: inheritance modifiers. final, open, abstract and override.

Photo by Slim Emcee (UG) the poet Truth_From_Africa_Photography on Unsplash

final: default

As we will see later, you need to mark a class with the open keyword to let it be extended. When we are changing a extended class the explicit open keyword, inform us that we should review the derived classes, and check if our changes in the super class are compatible with the subclasses.




Note: final by default and smart casting

if (input is Int) {
return input + 1 // Here there is no need for explicit casting.




Android-Kotlin Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store