docs: add example of using array decomposition (#7720)
parent
8724749728
commit
bbda30b816
|
@ -210,6 +210,12 @@ fn sum(a ...int) int {
|
||||||
println(sum()) // Output: 0
|
println(sum()) // Output: 0
|
||||||
println(sum(1)) // 1
|
println(sum(1)) // 1
|
||||||
println(sum(2,3)) // 5
|
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
|
## Symbol visibility
|
||||||
|
|
Loading…
Reference in New Issue