mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
22 lines
292 B
Go
22 lines
292 B
Go
|
struct A {
|
||
|
m map_int
|
||
|
}
|
||
|
|
||
|
fn (a mut A) set(key string, val int) {
|
||
|
a.m[key] = val
|
||
|
}
|
||
|
|
||
|
fn test_map() {
|
||
|
mut m := map[string]int{}
|
||
|
m['hi'] = 80
|
||
|
assert m['hi'] == 80
|
||
|
|
||
|
mut a := A{
|
||
|
m: new_map(1, sizeof(int))
|
||
|
}
|
||
|
a.m['one'] = 1
|
||
|
a.set('two', 2)
|
||
|
assert a.m['one'] == 1
|
||
|
assert a.m['two'] == 2
|
||
|
}
|