mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
21 lines
252 B
V
21 lines
252 B
V
fn setter[T](mut m map[T]int) fn (T, int) {
|
|
return fn [mut m] [T](x T, k int) {
|
|
m[x] = k
|
|
}
|
|
}
|
|
|
|
fn test_generics_closure_fn() {
|
|
mut m := {
|
|
f32(0.1): 1
|
|
}
|
|
|
|
f := setter(mut m)
|
|
f(0.2, 2)
|
|
|
|
println(m)
|
|
assert m == {
|
|
f32(0.1): 1
|
|
0.2: 2
|
|
}
|
|
}
|