19 Maps
A map associates a typed key with a typed value.
norm
main() {
Map<String, Integer> scores = Map<>()
scores.put(key: "Ada", value: 3)
scores.put(key: "Lin", value: 5)
printLine(scores["Ada"])
printLine(scores.containsKey("Lin"))
printLine(scores.size())
scores.put(key: "Ada", value: 7)
printLine(scores["Ada"])
printLine(scores.size())
}Expected output:
text
3
true
2
7
2put writes a key-value pair. The index read retrieves Ada's value, and containsKey checks another key. Writing Ada again replaces its value without increasing the entry count.
Try it: Write a new value for Ada and observe whether the entry count grows.
Precise rules: Reference.