Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Enumerable.generate enumerates the initial value, even if it doesn't pass the condition selector. #10

Open
trxcllnt opened this issue Sep 30, 2014 · 0 comments

Comments

@trxcllnt
Copy link

@mattpodwysocki

I've always understood Enumerable.generate() to approximate for-loop style control flow. Is this wrong? Whereas the for-loop prints nothing, the generate example prints an undefined value to the console.

var arr = ["a", "b", "c"];
for(var i = 3; i < arr.length; ++i) {
    console.log(arr[i]);
}
// prints nothing
var arr = ["a", "b", "c"];
Enumerable.generate(
    3,
    function(i) { return i < arr.length; },
    function(i) { return i + 1; },
    function(i) { return arr[i]; }
).forEach(console.log.bind(console));
// prints `undefined`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant