Python like dictionaries in Kotlin

I’m newbe in Kotlin thus sorry if I’m asking for someting obvious. Just wondering whether it is possible to achieve something similar to Python dictionaries in Kotlin namely (pseudocode):

dict1 = {“firstName”: “John”, “age”: 31, “married”:true}

in Kotlin so:
Some kind of map of properties of different types (Integer, Boolean, String) mapped by key (String).
Thanks for any hints

val dict1 = mapOf( 
    "firstName" to "John",
    "age" to 31,
    "married" to true

You get a Map<String, Any> from that sort of construct.


Do you know why they decided to use ‘to’ instead of : or => or something else known from other languages?

I guess, it’s because symbolic operators are (intentionally) pretty limited in Kotlin.

to is syntactically not an operator but an infix extension method on Any. So you can define your own alternatives to to as long as they are valid identifiers.