Comment

Comment by Xcelerate

Somewhat off-topic, but how are generators different than returning an object with a closed over environment? For instance, his first example in CoffeeScript would be:

    runningAvg = ->
            count = 0
            total = 0

            send: (value) ->
                    total += value
                    count += 1
                    total/count
                
    r = runningAvg()
    console.log r.send 10
    console.log r.send 5
    console.log r.send 0
    console.log r.send 0
parent Xcelerate 13 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton