thank you for taking the time to help me out. I'm attempting to learn node.js and have run in to the following problem when working on understanding inheritance:
var stream = require('stream');
var util = require('util');
util.inherits(Answers, stream.Readable);
function Answers(opt) {
stream.Readable.call(this, opt);
this.quotes = ["yes", "negatory", "possibly"];
this._index = 0;
}
Answers.prototype._read() = function() {
if (this._index > this.quotes.length) {
this.push(null);
}
else {
this.push(this.quotes[this._index]);
this._index += 1;
}
};
My error states that I have an invalid left-hand side assignment where I attempt to override the prototype of stream.Readable (line 12). I thought the call to
util.inherits(Answers, stream.Readable);
would allow me to overright the _read() function of stream.Readable. Any help would be very much appreciated. Thanks in advance!
Answers.prototype._read() ... you are assigning a value to a function call. Just change it to Answers.prototype._read = function() ....