From 515e83dcbcec129c7348fc086421f449f46103de Mon Sep 17 00:00:00 2001 From: Miccah Date: Sun, 25 Apr 2021 10:20:12 -0500 Subject: [PATCH] docs: correct one of the channel examples (#9865) --- doc/docs.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 632479aedb..200913fa16 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -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