Comment on Generator (yield keyword) support in CoffeeScript for Node.jsComments−wycats13yDoes 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)?−almostOP13yYes 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)
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:
Which is pretty ugly, but it's not something I've needed to do often with generators (in Python at least)