Please explain the difference between
Generators is something that can give the
next element of some sequence, if there is no element it returns
nil. It encapsulates iteration state and interface for iteration over a sequence.
A generator works by providing a single method, namely,
next(), which simply returns the next value from the underlying
Sequence represent a series of values. It is a type that can be iterated with a for...in loop.
Essentially a sequence is a generator factory; something that knows how to make generators for a sequence.
Collection is a
SequenceType that can be accessed via subscript and defines a
Collection is a step beyond a sequence in that individual elements of a collection can be accessed multiple times.