How to convert list to map in Kotlin

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

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 = friends.map { it.facebookId to it.points }.toMap()

Firefox Preview to Get Add-Ons Support

This is the new mobile browser that is based on the GeckoView engine and the Mozilla Android Components library set
06 February 2020   510

Mozilla developers have added support for add-ons to the codebase of the Firefox Preview mobile browser (Fenix), which is being developed to replace the Firefox edition for the Android platform. The new browser is based on the GeckoView engine and the Mozilla Android Components library set.

The ability to connect add-ons based on the WebExtension API is available for testing in the nightly builds of Firefox Preview. The item "Add-ons Manager" appeared in the menu, which shows the add-ons available for installation. In its current form, only uBlock Origin is present in the list of add-ons compatible with Firefox Preview. Support for other add-ons is expected later.

Get more at the official blog.