JetBrains is working toward the general release of Kotlin 1.4, an upgrade to the open source, general purpose language for JVM, Android, web, and native development that promises improvements to the standard library including the API.
In a bulletin posted on May 12, JetBrains detailed standard library improvements in the forthcoming Kotlin 1.4-M2 milestone release. An early version has been deployed to the Kotlin playground for developers to try out. Changes to the existing API are featured, including updating signatures and introducing new constants. Some functions have been relaxed to accept nulls.
val s: String? = null
println(s.toBoolean()) // false
(Note that Kotlin 1.3 will not compile this code.)
Other API-related code changes also are featured, such as
SIZE_BYTES, which are new constants in
Float. These contain the number of bits and bytes used to represent an instance of the type in binary form.
Also new in the Kotlin 1.4-M2 standard library:
- New array functions in the standard library include
shuffle(), which puts array elements in a random order, and
onEach(), which performs the given action on each array element and returns the array itself. Also, functions have been added for sorting array subranges.
- The collections API has been expanded to cover more real-life cases. A new set creation function,
set()NotNull(), makes a set