Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.
This repository was 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

Description

@trxcllnt

@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`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions