Lambdish / phunctional

⚡️ λ PHP functional library focused on simplicity and performance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does filter preserve keys?

matthewboman opened this issue · comments

What was the reason behind filter preserving the original array's keys? Is there a benefit to it? I'm most often filtering arrays where the key is an integer, so I'd expected filter to act more like it does in other languages creating a new array with values accessible by index.

I get that updating filter would lead to breaking changes, and there are probably times where the current implementation comes in handy, but it'd be useful to to have a function that filters an array and returns a new array that starts at zero.

If the maintainers feel like it would be useful and extend what phunctional is trying to do, I could work on an implementation.

commented

Any improvement its welcome @crashspringfield!

As you mention, is better if we do not introduce any breaking change.

Thanks!