RosettaCodeData/Task/Associative-array-Creation/V-(Vlang)/associative-array-creation.v

24 lines
362 B
Coq
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
fn main() {
// make empty map
mut my_map := map[string]int{}
2026-02-01 16:33:20 -08:00
// set value
2023-07-01 11:58:00 -04:00
my_map['foo'] = 3
// getting values
y1 := my_map['foo']
2026-02-01 16:33:20 -08:00
println(y1)
2023-07-01 11:58:00 -04:00
// remove keys
my_map.delete('foo')
2026-02-01 16:33:20 -08:00
println(my_map)
2023-07-01 11:58:00 -04:00
// make map with values
my_map = {
'foo': 2
'bar': 42
'baz': -1
}
2026-02-01 16:33:20 -08:00
println(my_map)
2023-07-01 11:58:00 -04:00
}