Tsallaka zuwa abun ciki
Justice Tech School

Maps

Maps hold key value pairs. Use [] to read and write, containsKey and entries.

Example
var m = {"a": 1, "b": 2};
m["c"] = 3;
print(m["a"]);
print(m["z"]);
print(m.containsKey("b"));
m.forEach((k, v) => print("$k=$v"));
print(m.keys.toList());

Exercise

Check a key.

m.("a")

Quiz Test

What does m["z"] return if missing?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.