Skip to content

preventing multiple parameters from having the same name is an antifeature #3223

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

Closed
olleicua opened this issue Oct 28, 2013 · 1 comment
Closed

Comments

@olleicua
Copy link

the following produces an error

foo = (_, _, _, bar) ->
  bar * 2

console.log(foo 1,2,3,4)
error: multiple parameters named '_'

In JavaScript you can do:

var foo = function(_, _, _, bar) {
  return bar * 2
}

console.log(foo(1,2,3,4))

which properly logs:

8

This can be very useful when dealing with apis that provide parameters that aren't needed. The default behavior in JS simply assigns overwrites the repeated variable with the last parameter it is bound to. This is a feature of JavaScript and a bug in CoffeeScript.

@vendethiel
Copy link
Collaborator

#1002

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

No branches or pull requests

2 participants