4 ms·
"So a generator is simply something that can give you the next element of some sequence of elements." Is this a common usage of the word "generator"? At least
by tlrobinson 12y ago
"So a generator is simply something that can give you the next element of some sequence of elements."
Is this a common usage of the word "generator"?
At least in JavaScript and Python you'd call that an "iterator", and a "generator" is a special type of function that acts as an iterator, using the "yield" keyword.
- nickfargo 12y agoA generator is an iterator created and returned by a generator function.