CoffeeScriptRedux
CoffeeScriptRedux copied to clipboard
Array Splice to remove element
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)
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 :+1:
+1 for making it work the same as it does in the original CoffeeScript
It will, @slang800.
When, @michaelficarra? The pulse for redux is looking mighty sparse.