
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
60 lines
1.2 KiB
Plaintext
60 lines
1.2 KiB
Plaintext
== Why is this an issue?
|
|
|
|
A generator without a ``++yield++`` statement is at best confusing, and at worst a bug in your code, since the iterator produced by your code will always be empty.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
function* myGen(a, b) { // Noncompliant
|
|
let answer = 0;
|
|
answer += a * b;
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
function* myGen(a, b) {
|
|
let answer = 0;
|
|
while (answer < 42) {
|
|
answer += a * b;
|
|
yield answer;
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Add a "yield" statement to this generator.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
``++function* xxx++``
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 5 Feb 2016, 15:52:49 Elena Vilchik wrote:
|
|
\[~ann.campbell.2] Could you add to description smth like "It even could be a bug in your problem as you your iterator produced by this generator function is always empty"?
|
|
|
|
And I would like to remove highlighting and specific message for return, I don't think it's worth that. Are you ok?
|
|
|
|
=== on 5 Feb 2016, 16:06:15 Ann Campbell wrote:
|
|
done [~elena.vilchik]
|
|
|
|
endif::env-github,rspecator-view[]
|