You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice, and a lot less verbose in some use cases, if we could support the index of a collection as an optional argument in the reduce function.
The implicit variable would be $$$ as it is in pluck, and if you named the variable it would be the third argument, making the new interface for reduce be:
(item, acc = [], index)
while still supporting the existing: (item, acc = [])
By making the index an optional third argument that isn't defined unless referenced in the function call, it should make existing implementations backwards compatible while providing a useful variable for complex reduce use cases.
The text was updated successfully, but these errors were encountered:
Agree this is very useful addition though it can not be added to the current reduce function without breaking compatibility, so this will require the introduction of a new reduce funtion like reduceWithIndex or something like this.
It would be nice, and a lot less verbose in some use cases, if we could support the index of a collection as an optional argument in the
reduce
function.The implicit variable would be
$$$
as it is inpluck
, and if you named the variable it would be the third argument, making the new interface forreduce
be:(item, acc = [], index)
while still supporting the existing:
(item, acc = [])
By making the index an optional third argument that isn't defined unless referenced in the function call, it should make existing implementations backwards compatible while providing a useful variable for complex
reduce
use cases.The text was updated successfully, but these errors were encountered: