Articles

Kotlin 1.1.2 version Features

by GeekOnJava - Hub for Java Android GeekOnJava

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 — foldreduceeachCount.

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 


Sponsor Ads


About GeekOnJava - Hub for Java Android Advanced   GeekOnJava

51 connections, 0 recommendations, 402 honor points.
Joined APSense since, January 29th, 2014, From California, United States.

Created on Dec 31st 1969 18:00. Viewed 0 times.

Comments

No comment, be the first to comment.
Please sign in before you comment.