5

Go channels can be used to communicate in between goroutines. Similarly, the yield and next syntax can be used to communicate between two generators. Am I right in my assumption? If not, where am I wrong?

Grzegorz Żur
  • 47,257
  • 14
  • 109
  • 105
codeNoob
  • 313
  • 1
  • 3
  • 11
  • 3
    See https://stackoverflow.com/questions/34464146/the-idiomatic-way-to-implement-generators-yield-in-golang-for-recursive-functi – Charlie Tumahai Oct 06 '17 at 19:34
  • Possible duplicate of [The idiomatic way to implement generators (yield) in Golang for recursive functions](https://stackoverflow.com/questions/34464146/the-idiomatic-way-to-implement-generators-yield-in-golang-for-recursive-functi) – Adrian Forsius Oct 07 '17 at 19:39

1 Answers1

2

A channel in Go is a general, multipurpose tool for communication between goroutines. It can be used to create a concurrent generator.

The yield keyword is a very specific tool that let you easily create a nonconcurrent generator.

Grzegorz Żur
  • 47,257
  • 14
  • 109
  • 105