|
|
|
|
|
by mort96
315 days ago
|
|
I'm surprised that the example requires lambdas... What's the purpose of the `|> foo(...)' syntax if the function has to take exactly one operand? Why is it necessary to write this? $arr
|> fn($x) => array_column($x, 'tags')
Why doesn't this work? $arr
|> array_column(..., 'tags')
And when that doesn't work, why doesn't this work? $arr
|> array_unique
|
|
So where in Python you would say e.g.
PHP requires the syntax As for the purpose of the feature as a whole, although it seems like it could be replaced with function composition as mentioned at the end of the article, and the function composition could be implemented with a utility function instead of dedicated syntax, the advantage of adding these operators is apparently [2] performance (fewer function calls) and facilitating static type-checking.[1] https://wiki.php.net/rfc/first_class_callable_syntax
[2] https://wiki.php.net/rfc/function-composition#why_in_the_eng...