13

Kotlin closed classes: how to compose with them - Notes of a Bearded Dev

 4 years ago
source link: https://jelmini.dev/post/2020-01-02-kotlin-classes-final-by-default/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
One of the most controversial choices by the Kotlin designers was to make classes final by default. This means we need to explicitly open them to allow subclassing. Moreover, functions on an open class must also be explicitly marked open to allow a subclass to override them.There were a lot of debate even before Kotlin 1.0 came out, as illustrated by this thread in the Kotlin forum. The main objections against defaulting to closed classes are the following:

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK