mirror of
https://github.com/bloeys/cogo.git
synced 2025-12-29 08:58:19 +00:00
Support for basic for loops
This commit is contained in:
7
main.go
7
main.go
@ -9,6 +9,8 @@ import (
|
||||
"github.com/bloeys/cogo/cogo"
|
||||
)
|
||||
|
||||
var loop = 0
|
||||
|
||||
func test(c *cogo.Coroutine[int, int]) (out int) {
|
||||
if cogo.HasGen() {
|
||||
return test_cogo(c)
|
||||
@ -29,6 +31,11 @@ func test(c *cogo.Coroutine[int, int]) (out int) {
|
||||
c.Yield(c.In)
|
||||
}
|
||||
|
||||
for loop = 0; loop < 10; loop++ {
|
||||
println("\nFor loop tick number:", loop)
|
||||
c.Yield(loop)
|
||||
}
|
||||
|
||||
println("\nTick 2")
|
||||
c.Yield(2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user