Programming Books

Main Menu

  • Home
  • Phyton programming
  • Java programming
  • Php programming
  • C++ programming
  • Additional Topics
    • Programming industry
    • Privacy Policy
    • Terms and Conditions

Programming Books

Header Banner

Programming Books

  • Home
  • Phyton programming
  • Java programming
  • Php programming
  • C++ programming
  • Additional Topics
    • Programming industry
    • Privacy Policy
    • Terms and Conditions
Java programming
Home›Java programming›Kotlin 1.6.0 released

Kotlin 1.6.0 released

By Brandy J. Richardson
December 7, 2021
0
0


JetBrains released Kotlin 1.6.0 which ships with the standard language and library features of Kotlin 1.5.30 which are now stable. One of the new language features is sealed when statements:

sealed class Employee {
    data class Developer(val languages: List) : Employee()
    data class Operations(val operatingSystems: List) : Employee()
}

fun printInformation(employee: Employee) {
    when (employee) {
        is Employee.Developer -> printLanguages(employee.languages)
    }
}

Kotlin provides already verified when expressions for sealed classes, enumerations, and Boolean types for completeness. Use a non-exhaustive list when The instruction will result in an error in Kotlin 1.7, but for now Kotlin 1.6.0 will display the following warning:

Non exhaustive 'when' statements on sealed class/interface will be 
prohibited in 1.7, add 'is Operations' branch or 'else' branch instead

Coroutines now support implementation suspend functional types as supertypes. Previously, it was only possible to use lambdas and suspension function references for the desired behavior. Now a separate class can be used to implement the functional type of suspension:

class OrderManager : suspend () -> Unit {
    override suspend fun invoke() { ... }
}

fun buy(action: suspend () -> Unit) {}

Conversions from regular functional types to suspended functional types are now implicitly converted for any expression form after being previously limited to functional literals and callable references. This allows a regular function to be used as a parameter for a type of suspension:

val regularFunction = ::function
flow.collect(regularFunction)

Type inference for recursive generic types is now possible based on the upper bounds of the type parameter.

Changes in the standard library include readln() as an alternative for readLine()!! which throws an exception at the end of the file. In the same way, readlnOrNull() can be used as an alternative to readLine() that comes back null when the end of the file is reached.

The typeOf() feature was already available as an experimental API for the JVM platform and is now officially available for all platforms.

Collection builders love buildList(), buildMap() and buildSet() are now stable and return serializable collections in their read-only state.

API Duration toComponents() the function now accepts a Long instead of a Int for the number of days to avoid problems with larger numbers. The DurationUnit enum is no longer a type alias for java.util.concurrent.TimeUnit on the JVM because it was not deemed necessary. Extension properties like Int.seconds are available through the Companion of the Duration class to limit their scope.

Other now stable functions include rotateLeft() and rotateRight() for rotations of integer bits, splitToSequence() which divides a string based on a regular expression, Comparable.compareTo() can now be used in infix notation and replace() and replaceFirst() now give the same results on the JVM and JS for group references.

With Kotlin 1.6.0 it is possible to develop based on the three previous API versions and the current stable version which currently includes 1.3, 1.4, 1.5 and 1.6.

Kotlin’s @kotlin.annotation.Repeatable is now compatible with Java and accepts retention and can be used repeatedly. Java repeatable annotation also works in Kotlin.

A new experimental version, which should be used for evaluation purposes only, of the memory manager is provided to remove technical differences between native platforms and JVM. This allows for a leak-free concurrent programming primitive without the need for annotations or other configuration on the part of developers. Kotlin / Native now also supports Xcode 13 and allows compilation of Windows targets on all hosts that support Kotlin / Native.

Node.js and Yarn downloads for Kotlin / JS projects can be disabled when they are already installed.

The Kover Gradle plugin is now available to measure code coverage for Kotlin code built with the Kotlin JVM compiler. Before the release of the Kover plugin, measuring code coverage was a challenge because, for example, JaCoCo was not integrated into the Gradle toolchain and cross-platform projects.

Kotlin’s documentation provides a full overview, including examples, of all the changes in this release.


Related posts:

  1. Start a new career or discover your new hobby obsession with these $ 20 lesson package deals
  2. The new wave of IoT development
  3. What exactly is computer programming? The technician’s guide
  4. Senior Full Stack Java Developer – Centurion – R600 to R750 per hour at e-Merge IT Recruitment

Archives

  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • January 2021
  • December 2019
  • November 2019
  • October 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2017

Categories

  • C++ programming
  • Java programming
  • Php programming
  • Phyton programming
  • Programming industry

Recent Posts

  • Rust could be included in the Linux kernel in 5.20
  • [Around the Hotels] Promotions and packages
  • AWS Mainframe Modernization Service Now Generally Available
  • Rates rise for private student loans, but borrowers with good credit can still save
  • Lycoming College student secures his future with the Ministry of Defense | Education
  • Privacy Policy
  • Terms and Conditions