It is ok to have named generators in objects:
let foo = {
acc: 42,
*generator () {
yield this.acc++
this.acc += 2
yield this.acc
}
}
It is also ok to have unnamed generators in classes:
class Foo {
acc = 42
generator = function* () {
yield this.acc++
this.acc += 2
yield this.acc
}
}
Why is it not ok to have named generators in classes:
class Foo {
acc = 42
*generator () {
yield this.acc++
this.acc += 2
yield this.acc
}
}