-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmap_int_string.ko
More file actions
32 lines (25 loc) · 853 Bytes
/
Copy pathmap_int_string.ko
File metadata and controls
32 lines (25 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module map_int_string {
meta {
description: "Demonstrates Map<Int, String> operations"
purpose: "Example of generic Map with Int keys and String values"
version: "1.0.0"
}
fn main() {
let names: Map<Int, String> = map_new()
map_insert(names, 1, "one")
map_insert(names, 2, "two")
map_insert(names, 3, "three")
let first: String = map_get(names, 1)
println(f"1 = {first}")
let second: String = map_get(names, 2)
println(f"2 = {second}")
let third: String = map_get(names, 3)
println(f"3 = {third}")
let len: Int = map_length(names)
println(f"Map size: {len}")
// Overwrite
map_insert(names, 1, "uno")
let updated: String = map_get(names, 1)
println(f"1 updated = {updated}")
}
}