How to convert list to map in Kotlin

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

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()

Firefox to Launch Preview Browser

Firefox Preview uses the GeckoView engine built on the basis of Firefox Quantum and team states its 2x faster than previous Firefox browser for Android
28 June 2019   419

Mozilla introduced the first trial release of the Firefox Preview browser, developed under the codename Fenix ​​and aimed at initial testing by interested enthusiasts. The release is distributed through the Google Play catalog, and the code is available on GitHub. After stabilization of the project and implementation of all conceived functionality, the browser will replace the current edition of Firefox for Android, the release of which will be discontinued starting with the September release of Firefox 69 (only corrective updates of the Firefox 68 ESR branch will be published).

Firefox Preview uses the GeckoView engine built on the basis of Firefox Quantum technologies and a set of Mozilla Android Components libraries, which are already used to build Firefox Focus and Firefox Lite browsers. GeckoView is a version of the Gecko engine, designed as a separate library that can be updated independently, and Android Components includes libraries with typical components that provide tabbed browsing, automatic input completion, search hints, and other browser features.

Firefox Preview
Firefox Preview

These are some features developers claim their app has:

  • Faster than ever: Firefox Preview is up to 2x faster than previous versions of Firefox for Android.
  • Fast by design: with a minimalist start screen and bottom navigation bar, Preview helps you get more done on the go.
  • Stay organized: Make sense of the web with Collections, a new feature that helps you save, organize, and share collections of sites. Quickly save and return to tasks like your morning routine, shopping lists, travel planning and more.
  • Tracking Protection on by default: Everyone deserves freedom from invasive advertising trackers and other bad actors so Firefox Preview blocks trackers by default. The result is faster browsing and fewer annoyances.