Skip to content

Comment on Generator (yield keyword) support in CoffeeScript for Node.js

Comments

Does this mean that the mere presence of the word `yield` turns a function into a generator? Is there any way to build a yield-less generator (say, a noop generator for an API that requires a generator)?

Yes it does.

If you did want a generator that didn't yield anything I guess you could write:

    myEmptyGen = ->
      yield if false
Which is pretty ugly, but it's not something I've needed to do often with generators (in Python at least)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.