tc39 / proposal-array-last

A JavaScript TC39 Proposal for getting the last element from an array
311 stars 13 forks source link

Groovy has all these syntaxes #3

Closed antony closed 6 years ago

antony commented 6 years ago

Groovy has all of these syntaxes (including reverse), and I miss them. Would love to see this implemented.

I made a little demo:

https://groovyconsole.appspot.com/script/5073772172279808

If you hit 'edit' in console and then 'execute' you can see that these all work as you might imagine.

Btw I realise now that the array - 'three' syntax might be confusing. It's literally filtering the element 'three' out of the array, not the element at index 3.

keithamus commented 6 years ago

Certainly picking one proposal here does not stop us from picking another up later. Personally I could see both .last() and the 1:3 style syntax gaining traction.

keithamus commented 6 years ago

To keep this focussed on just the one problem domain, the README has been updated to just 1 solution, and I'm going to close this as the 1:3 style syntax is out of scope. I would still like to see this syntax though! I may make a proposal one day, unless someone beats me to it 😉