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

Array Splice to remove element #309

Open
DavidSouther opened this issue Apr 22, 2014 · 4 comments
Open

Array Splice to remove element #309

DavidSouther opened this issue Apr 22, 2014 · 4 comments

Comments

@DavidSouther
Copy link

DavidSouther commented Apr 22, 2014

In CoffeeScript Redux, this does not compile:

arr = ['a', 'b', 'c']
idx = 1
arr[idx..idx] = []

http://michaelficarra.github.io/CoffeeScriptRedux/#try:arr%20%3D%20%5B'a'%2C%20'b'%2C%20'c'%5D%0Aidx%20%3D%201%0Aarr%5Bidx..idx%5D%20%3D%20%5B%5D%0A

In CoffeeScript, it compiles to

var arr, idx, _ref;

arr = ['a', 'b', 'c'];

idx = 1;

[].splice.apply(arr, [idx, idx - idx + 1].concat(_ref = [])), _ref;

Which has the effect of in-place removing the idx element from the array.

http://coffeescript.org/#try:arr%20%3D%20%5B'a'%2C%20'b'%2C%20'c'%5D%0Aidx%20%3D%201%0Aarr%5Bidx..idx%5D%20%3D%20%5B%5D%0A%0Aalert(arr)

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1781204-array-splice-to-remove-element?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).
@DavidSouther
Copy link
Author

NB if the answer is, "Don't use this syntax, use splice as it's intended", that's totes cool, but a mention of that in the know breaking changes would be 👍

@notslang
Copy link

+1 for making it work the same as it does in the original CoffeeScript

@michaelficarra
Copy link
Owner

It will, @slang800.

@DavidSouther
Copy link
Author

When, @michaelficarra? The pulse for redux is looking mighty sparse.

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