nozavroni / csvelte

🕺🏻 CSV and Tabular Data library for PHP
http://phpcsv.com/
Other
6 stars 0 forks source link

Would be useful to have a fold method that defaulted to a new collection #186

Closed nozavroni closed 6 years ago

nozavroni commented 6 years ago

I find myself doing this a lot:

$collection->fold(function($col, $val, $key, $i) {
            return $col->whatever();
        }, new Collection);

It might be useful to add a method like this:

$collection->cfold(function(Collection $col, $val, $key, $i) {
    return $col->whatever();
});

Not a huge difference I know, but having that new Collection at the end just feels very clunky. Maybe there's an even better way to accomplish the same thing. Think about it.

nozavroni commented 6 years ago

This is in the wrong repository. Should have been posted here: https://github.com/nozavroni/collect