Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterator clarification #38

Closed
pirfalt opened this issue Mar 19, 2014 · 3 comments
Closed

Iterator clarification #38

pirfalt opened this issue Mar 19, 2014 · 3 comments

Comments

@pirfalt
Copy link

pirfalt commented Mar 19, 2014

Your explanation is great, but I have tried to find definitive answer to what api the iterator will have. Your explanation is another example to support one of the two I have found, do you know if it is the latest? And could you make that clear in the document?

The two I have found are:

// Yours and (https://people.mozilla.org/~jorendorff/es6-draft.html#sec-common-iteration-interfaces)
var iterable = {
  [Symbol.iterator]() {
    let pre = 0, cur = 1;
    return {
      next() {
        [pre, cur] = [cur, pre + cur];
        return { done: false, value: cur }
        // alt. return { done: true, value: IteratorReturn || undefined }
      }
    }
  }
}

and

// Harmony wiki. (http://wiki.ecmascript.org/doku.php?id=harmony:iterators)
var iterable = {
  [Symbol.iterator]() {
    let pre = 0, cur = 1;
    return {
      next() {
        [pre, cur] = [cur, pre + cur];
        return cur
        // alt. throw new StopIteration()
      }
    }
  }
}
@domenic
Copy link
Contributor

domenic commented Mar 19, 2014

Everything in this repo is the latest always; the wiki is generally out of date.

The fact that this repo matches the spec, as you noted, is a clue in this regard. Plus the giant bold "This page is out of date" at the top of the wiki.

@pirfalt
Copy link
Author

pirfalt commented Mar 19, 2014

Thanks, thats really good to know. I found it very unclear where to find correct information before.

@pirfalt pirfalt closed this as completed Mar 19, 2014
@getify
Copy link
Contributor

getify commented Mar 19, 2014

To answer concretely, the return value will be { done: ... , value: ... }. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants