# Maps

map of K to V associates typed keys with typed values. Map literals use key to value pairs.

Last updated: 2026-09-09

Package: language | Status: experimental

Tags: Contains, Remove, collections, cpu, language, map, of, to, yeho

Use a map for lookup by identity or name when sequential scanning would hide the intent.

```yh
map of KeyType to ValueType
[key to value, key to value]
map[key]
```


## Lookup table

Use a map for lookup by identity or name when sequential scanning would hide the intent.

Verification: type checked

```yh
map of text to int power = ["sun" to 100, "moon" to 70]
int sunPower = power["sun"]

if power.Contains("moon")
{
    Console.Log(Text.From(power["moon"]))
}

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.language__maps"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/language--maps/complete-0 --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Map literals and list literals both use brackets; to distinguishes a map pair.

Collections are experimental.

Source: yeho/parser_types.cpp parseMapTypeRef; parser_expressions.cpp parseListOrMapLiteralExpression

AI training permission: https://demonhunterlabs.com/ai-use
