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

Prototype methods that accept a callback #18

Open
rwaldron opened this issue Nov 9, 2017 · 3 comments
Open

Prototype methods that accept a callback #18

rwaldron opened this issue Nov 9, 2017 · 3 comments

Comments

@rwaldron
Copy link

rwaldron commented Nov 9, 2017

I didn't see any examples of this, so I'm curious:

let numbers = [1, 2, 3];
let mapped =  numbers.map {
  // ...
}

Does this work?
How would I get the value, index, object args?

@samuelgoto
Copy link
Owner

samuelgoto commented Nov 9, 2017 via email

@rwaldron
Copy link
Author

rwaldron commented Nov 9, 2017

https://github.com/samuelgoto/proposal-block-params#bindings

Hopefully any suggestions that include special properties of a this object are off limits until #16 is resolved.

@samuelgoto
Copy link
Owner

samuelgoto commented Nov 27, 2017

To be clear, this is as close as it would get in the current formulation (without any assumptions made on the this reference).

let numbers = [1, 2, 3];
let mapped =  map(numbers) do (value, index) {
  // ...
  console.log(`${value} ${index}`);
}

Does that sound reasonable?

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

2 participants