Null safety | Enum class | Immutability |
---|---|---|
Type Inference | Properties & Fields | Data class |
Lambda | Extension Functions | High order functions |
Type-safe builder | Collection APIs | Kotlin-Java Interoperable |
val a = (1..10) + (1..10)
a.all { it > 0 } a.subtract(5..10)
a.any { it % 2 == 0 } a.sortedWith { .... }
a.average() a.sum()
a.distinct() a.take(3)
a.dropWhile { it < 5 } a.toList()/a.toArrayList()
a.filterNot { it > 0 } a.toSet()/a.toHashSet()
a.groupBy { if (it < 3) "<3" else ">3" } a.toCollection(MyAwesomeCollection())
a.intersect(2..4) a.toLinkList()
a.joinToString("-") a.toMap({ if (it % 2 == 0) "even" else "odd" },
{ it.toString })
a.max(), a.min() a.map { it to it.toString() }.unzip()
a.none { it < 1 } a.withIndex()
a.reversed() a.union(10..20)
a.sortedBy { it % 3 == 0 } a.zip(10..20)