Syntax

Kotlin Create a Map Syntax

In Kotlin, create a map: creates key-value pairs — val ages = mapOf("Ada" to 36)

Quick Answer

Syntax
val ages = mapOf("Ada" to 36)
KotlinSyntax

Create a Map

Code example
val ages = mapOf("Ada" to 36)

Creates key-value pairs.

Learn More

How to create a map in Kotlin

  1. Open your Kotlin file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Kotlin Create a Map Syntax

Use val ages = mapOf("Ada" to 36).

Related Syntax References

Frequently asked questions

What is the Kotlin syntax for create a map?

Use this pattern: val ages = mapOf("Ada" to 36)

Can I copy this Kotlin code example?

Yes. Use Copy code and adapt the example to your program.

Is this Kotlin syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify