Documentation menu

Data Structures

Dicts

String-keyed maps. Literal syntax mirrors JSON: {"key": value, ...}.

New to coding?

Copy the examples exactly first. Run them. Then change one number or word and run them again. You are not expected to memorize the command lists.

1

Creating and accessing

Try this code
user = {"name": "Ada", "score": 42};
user["name"]           // "Ada"
user["score"] = 50;     // update
user["active"] = true;  // add a new key
2

Nested access & chained assignment

Try this code
data = {"list": [1, 2, 3]};
data["list"][1] = 42;     // chained index assignment through a dict
3

Common functions

Try this code
keys(user)               // ["name", "score", "active"]
values(user)              // ["Ada", 50, true]
has(user, "score")        // true
get(user, "email", "n/a")  // "n/a" — default if missing
remove(user, "active")     // delete a key
merge({"a":1}, {"b":2})    // {"a":1, "b":2} — second wins on conflict
4

Iteration

for-in over a dict walks its keys.

Try this code
for key in user {
    print "{key}: {user[key]}";
}