Now Kotlin can be learned on the phone

Developer from India created an application for Kotlin studying on the go
30 June 2017   448

A statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code

Vicky Chijwani, young coder from India, created an application for Android called Kotlin Koans. It is designed for stugying Kotlin.

Learning process consists of 41 challenges, that last for few minutes. In each challenge, you will be able to read some documentation and write a code to pass the test. Application provides feedback with detailed desciption on your errors. Tips are also available.

Kotlin Koans learning process

The application is written in Kotlin and is open-source, so you are able to "hack" it.

How to convert list to map in Kotlin

Two ways to convert list to map in Kotlin, with code examples
31 October 2017   503

For example, you have a list of strings like:

val list = listOf("a", "b", "c", "d")

and you need to convert it to a map, where the strings are the keys.

There are two ways to do this:

The first and most performant is to use associateBy function that takes two lambdas for generating the key and value, and inlines the creation of the map:

val map = friends.associateBy({it.facebookId}, {it.points})

The second, less performant, is to use the standard map function to create a list of Pair which can be used by toMap to generate the final map:

val map = { it.facebookId to it.points }.toMap()