Nothing Type in Kotlin

Kotlin 1.1.2 version launched with 15 features

Standard Library API in Kotlin 1.1.2 version

Previously we discuss some disadvantage of Kotlin and what bugs resolved in Kotlin 1.1.2 version.

New Standard Library API in Kotlin 1.1.2 version

Here we introduce new functions and classes that are going to be published in Kotlin 1.1.2 version.

takeIf() and also()

These are two general-purpose extension functions applicable to any receiver.

also is like apply: it takes the receiver, does some action on it, and returns that receiver.
The difference is that in the block inside apply the receiver is available as this,
while in the block inside also it’s available as it (and you can give it another name if you want).

Coroutines

One of the hottest features introduced in the first milestone of version 1.1 and redesigned in next ones are coroutines. It’s a mechanism that provides ability to improve asynchronous programming in Kotlin. The aim is to eliminate a well-known callback hell with suspended computation.

groupingBy()

This API is to group a collection by key and fold each group in the same time. It consists of two parts: groupingBy function, and terminal operations — fold, reduce, eachCount.

First you invoke collection.groupingBy { key } function, which just returns a Groupinginstance binding the provided key selector to the collection of elements. Then you call one of folding operations available for Grouping, which iterates the collection and populates the resulting map with the result of folding elements in each group.

minOf() and maxOf()

These functions can be used to find the lowest and greatest of two or three given values, where values are primitive numbers or Comparable objects. There is also an overload of each function that take an additional Comparator instance, if you want to compare objects that are not comparable themselves.



Complete list with code snippet >> : Whats new features in Kotlin 1.1.2 version 

Comments