2 ms·
> I don’t know any other language with lambdas which requires me to spell out explicitly which variables it should close over PHP closures have to specify whic
by DCoder 6y ago
> I don’t know any other language with lambdas which requires me to spell out explicitly which variables it should close over
PHP closures have to specify which variables they close over, and whether it's done by-val or by-ref [0].
Nowadays there's also a shorthand single-expression-closure syntax that closes implicitly and by value [1].
[0]: https://www.php.net/manual/en/functions.anonymous.php#example-167 https://www.php.net/manual/en/functions.anonymous.php#exampl...
[1]: https://www.php.net/manual/en/functions.arrow.php https://www.php.net/manual/en/functions.arrow.php