= Point(30, 40) >>> println(p1 + p2) Point(x=40, y=60) Unpack arguments with spread operator Similar to Python, the spread operator asterisk (*) unpacks an array's contents as comma-separated arguments to a function: fun main(args: Array<String>) { val list = listOf("args: ", *args) println(list) } Destructuring declarations Destructuring declarations decompose an object into multiple variables at once, e.g. a 2D coordinate object might be destructured into two integers, and . For example, the object supports destructuring to simplify access to its key and value fields: for ((key, value) in map) println("$key: $value") Nested functions Kotlin allows local functions to be declared inside of other functions or methods. class User(val id: Int, val name: String, val address: String) fun saveUserToDb(user: User) { fun validate(user: User, value: String, fieldName: String) { require(value.isNotEmpty()) { "Can't save user ${user.id}: empty $fieldName" } } validate(user, user.name, "Name") validate(user, user.address, "Address") // Save user to the database ... } Classes are final by default In Kotlin, to derive a new class from a base class type, the base class needs to be explicitly marked as "open". This is in contrast to most object-oriented languages such as Java where classes are open by default. Example of a base class that is open to deriving a new subclass from it. // open on the class means this class will allow derived classes open class MegaButton { // no-open on a function means that // polymorphic behavior disabled if function overridden in derived class fun disable() { ... } // open on a function means that // polymorphic behavior allowed if function is overridden in derived class open fun animate() { ... } } class GigaButton: MegaButton() { // Explicit use of override keyword required to override a function in derived class override fun animate() { println("Giga Click!") } } Abstract classes are open by default Abstract classes define abstract or "pure virtual" placeholder functions that will be defined in a derived class. Abstract classes are open by default. // No need for the open keyword here, it’s already open by default abstract class Animated { // This virtual function is already open by default as well abstract fun animate() open fun stopAnimating() { } fun animateTwice() { } } Classes are public by default Kotlin provides the following keywords to restrict visibility for top-level declaration, such as classes, and for class members: public, internal, protected, and private. When applied