Guard situations, launched in Kotlin 2.1.0 final November, are actually secure. Guard situations enable for together with multiple situation for the branches of a when
expression, making advanced management flows extra specific and concise, JetBrains mentioned. Moreover, code construction is flattened with this function.
A brand new compiler possibility in Kotlin 2.2.0, -XWarning-level
, is designed to supply a unified means of managing compiler warnings in Kotlin initiatives. Beforehand, builders solely may apply normal module-wide guidelines, resembling disabling all warnings with nowarn
or turning warnings to compilation errors with -Werror
. With the brand new possibility, builders can override normal guidelines and exclude particular diagnostics in a constant means.
Different new options and enhancements in Kotlin 2.2.0: