How are Go channels different from JavaScript generators?

Issue

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?

Solution

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.

Answered By – Grzegorz ┼╗ur

Answer Checked By – Pedro (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.