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

docs: correct one of the channel examples (#9865)

This commit is contained in:
Miccah 2021-04-25 10:20:12 -05:00 committed by GitHub
parent 3ab6088918
commit 515e83dcbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2804,13 +2804,13 @@ Objects can be pushed to channels using the arrow operator. The same operator ca
pop objects from the other end:
```v
ch := chan int{}
ch2 := chan f64{}
// make buffered channels so pushing does not block (if there is room in the buffer)
ch := chan int{cap: 1}
ch2 := chan f64{cap: 1}
n := 5
x := 7.3
ch <- n
// push
ch2 <- x
ch <- n
ch2 <- 7.3
mut y := f64(0.0)
m := <-ch // pop creating new variable
y = <-ch2 // pop into existing variable