-
Notifications
You must be signed in to change notification settings - Fork 13
Using iterable rest syntax #31
Comments
I really like this, it can provide a great deal of flexibility in getting first/last elements, I could imagime it being used like |
if this worked with just the three dots, I’d also expect to be able to put a binding there and collect the third through penultimate items. Also, I’d expect |
I assume you mean converting it to |
Yes, exactly that :-) |
I think they can optimize this for arrays that have not been patched. For anything else, yes, I think they'll have to consume the iterator. |
I like the idea, python support similar feature. But there are some problems:
|
Maybe |
Have an idea and create a gist for it: https://gist.github.com/hax/285172c95550d3a46c4c997a13ce3614 |
I recently had the need to get the last-ish elements again. Twice actually:
Getting
matchIndex
fromString.p.replace
when using a function:Getting the last element of an array of
IntersectionObserverEntry
:I propose repurposing iterable's rest
...
syntax (with an optional binding) to get the last (or last-ish) elements:It's not perfect (there's no equivalent way to set the last item), but it seems natural with destructuring syntax. We just need to prevent multiple
...
from being used it the same iterable destructure.The text was updated successfully, but these errors were encountered: