mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: add example of using array decomposition (#7720)
This commit is contained in:
parent
8724749728
commit
bbda30b816
@ -210,6 +210,12 @@ fn sum(a ...int) int {
|
||||
println(sum()) // Output: 0
|
||||
println(sum(1)) // 1
|
||||
println(sum(2,3)) // 5
|
||||
|
||||
// using array decomposition
|
||||
a := [2,3,4]
|
||||
println(sum(a...)) // <-- using postfix ... here. output: 9
|
||||
b := [5, 6, 7]
|
||||
println(sum(b...)) // output: 18
|
||||
```
|
||||
|
||||
## Symbol visibility
|
||||
|
Loading…
Reference in New Issue
Block a user