Concise
Safe
Expressive
Asynchronous
Interoperable
// More than 30% fewer lines of code compared to Java
// (based on the experience of Duolingo and other companies)

data class Book (
    val title: String,                         // + automatically generated equals(),
    val year: Int                              // hashCode(), toString(), and copy()
)
fun century(year: Int) = (year - 1) / 100 + 1  // Top-level function,
                                               // single-expression body
fun main() {
    val books = listOf(                        // Construct a list
        Book("Don Quixote", 1605),             // No `new` keyword
        Book("The Lord of the Rings", 1955)
    )
    val classics = books.filter { century(it.year) < 20 } // Trailing single-argument lambda
    println("Classic books: $classics")                   // Calls toString() for Book
}
Get started ↗