Useful features
- A lot less boilerplate than Java
data class
es – basically custom tuples. Allows convenient destructuring declarations too.- Has access to the data structures in the Java standard library (
TreeMap
,HashMap
,PriorityQueue
etc.), and also can useBigInteger
andBigDecimal
if needed - Functional idioms for collection manipulation;
map
,fold
,filter
, etc. inline class
es – allows the creation of a new type that wraps over a base type, but that is represented by an underlying type at runtime. Especially useful for "modulo $$$10^9 + 7$$$" problems, as I keep aModInt
template that overloads the arithmetic operators appropriately, but is represented as a plainint
in JVM runtimerun
function – great way to write code that needs to shortcut (return@run "NO"
) without having to write a new function and pass every relevant argument- functions in functions – functions can be defined within e.g. the
main
function, so again, no having to pass lots of arguments or global variables