everything is open by default, unless you add the keyword final • In Kotlin everything is closed by default, unless you add the keyword open • Prefer composition when it's possible • A data class cannot be open • Inheritance breaks equality
Base(val name: String) data class Derived(name: String, val secondName: String): Base(name) val base = Base("base") val derived = Derived("base", "other") base == derived // true derived == base // false
// This is fine val nullableString: String? = something.getString() // Type mismatch: required String found String? val notnullString: String = something.getString() The compiler is now able to help us
be declared both as top level functions or inside a class • They don't really modify the receiver class • They are compiled as static functions only if they are top level and so they are also dispatched statically!
build cache since Kotlin 1.2.20 (add org.gradle.caching=true in your gradle.properties) • Avoid recompilation of Kotlin file adding kotlin.incremental.usePreciseJavaTracking=true to your gradle.properties (experimental!) • Gradle 4.7 supports incremental annotation