Description
I think we could improve the syntax adding Scala/Haskell "ignore" syntax in destructuring
[a, _, b, c] = array
would be compiled to
a = array[0], b = array[2], c = array[3]
instead of
a = array[0], _ = array[1], b = array[2], c = array[3]
It does not need to be _, it could be any other character, but it would clean the compiled code and improve memory usage avoiding creating a variable _ with a value we will not use
An better example. RxJs has this "How to use with jQuery"
$("#input").toObservable("keyup")
.map (e) -> e.target.value
.flatMapLatest ajaxCall
.subscribe (data) ->
results = data[1]
$.each results, (_, result) -> //Do Something
instead of results = data[1] we could use [_, results] = data
But the problem is, when we do this the compiler generates this
_ = data[0], results = data[1]
What Im proposing is to generate something like this
results = data[1] and ignore the _ = data[0]