Re: [RFC] Pipe Operator
| From: | Fleshgrinder | Date: | Sat, 30 Apr 2016 15:55:58 +0000 |
| Subject: | Re: [RFC] Pipe Operator | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92991@lists.php.net to get a copy of this message | ||
On 4/30/2016 5:51 PM, Fleshgrinder wrote:
> $ret = scandir($arg)
> |> array_filter($$, function($x) { return $x !== '.' && $x !=
> '..'; })
> |> array_map(function ($x) use ($arg) { return $arg . '/' . $x; }, $$)
> |> getFileArg($$)
> |> array_merge($ret, $$);
This should actually be formatted as to be fair contender to the
procedural example:
$ret = scandir($arg)
|> array_filter($$, function ($x) {
return $x !== '.' && $x !== '..';
})
}> array_map(function ($x) use ($arg) {
return $arg . '/' . $x;
}, $$)
|> getFileArg($$)
|> array_merge($ret, $$);
Not a big difference now...
$files = scandir($arg);
$files = array_filter($files, function ($x) {
return $x !== '.' && $x !== '..';
});
$files = array_map(function ($x) use ($arg) {
return $path . '/' . $x;
}, $files);
$ret = array_merge($ret, getFileArg($files));
..the only thing that bugs me in the procedural code is the fact that
array_filter and array_map take their arguments in different order. :P
--
Richard "Fleshgrinder" Fussenegger
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc