1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

docs: fix functions in array/map example (#8695)

This commit is contained in:
glebbash
2021-02-12 21:10:54 +02:00
committed by GitHub
parent 0b777c68c3
commit aa548f45ea
5 changed files with 32 additions and 4 deletions

View File

@ -1700,14 +1700,15 @@ fn main() {
res := run(5, fn (n int) int {
return n + n
})
println(res) // "10"
// You can even have an array/map of functions:
fns := [sqr, cube]
println((10)) // "100"
println(fns[0](10)) // "100"
fns_map := map{
'sqr': sqr
'cube': cube
}
println((2)) // "8"
println(fns_map['cube'](2)) // "8"
}
```