Support for basic for loops

This commit is contained in:
bloeys
2022-11-02 07:56:45 +04:00
parent d8748b6168
commit 1f08fec1af
3 changed files with 132 additions and 4 deletions

View File

@ -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)