blob: ebcb34801067a834528c6ce9b0620805294e748f [file] [log] [blame]
function RangeIterator(range) {
this.range = range;
this.current = this.range.low;
}
RangeIterator.prototype.next = function next() {
if (this.current > this.range.high) {
throw new Error();
} else {
return this.current++;
}
};
function Range(low, high) {
this.low = low;
this.high = high;
}
Range.prototype.__iterator__ = function __iterator__() {
return new RangeIterator(this);
};
// Nothing wrong with a function named __iterator__
function __iterator__() {
return "I have a stupid name!";
}