Re: [RFC] Pipe Operator
| From: | François Laupretre | Date: | Sat, 14 May 2016 10:24:15 +0000 |
| Subject: | Re: [RFC] Pipe Operator | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-93327@lists.php.net to get a copy of this message | ||
Le 13/05/2016 à 20:16, Sara Golemon a écrit :
Just to verify, you're suggesting an end-state something like this? $ret = array(1,2,3) |> array_map(function($x) { return $x * 2; }) // lhs implicitly passed as second arg |> array_sum(); // implicitly passed as only arg (first position) // $ret === int(12)Right. And also : array(1,2,3) |> array_map(function($x) { return $x * 2; }) |> $intermediate_var |> array_sum() |> $ret; Talking about arrays, I am also thinking of a '[]>' operator (name may vary). This would take an array as input, and output another array, where every value would have been run through the function. The keys would be preserved. Example : array('a','b','key' => 'c') []> ord(); // produces [ 97, 98, 'key' => 99 ] Regards François