user-documentation
user-documentation copied to clipboard
Document how lambdas capture local variables
We should explain they are captured "by value", not "by reference", with specific examples:
- example how
$captured_variable = ...
doesn't change the variable outside the lambda - example how
Ref
can be used to work around that (or is this a bad suggestion that we shouldn't encourage?) - example how
$captured_object->var = ...
works
If this is already explained somewhere, we could just link to that, but I couldn't find it anywhere.
- Build ID: HHVM=HHVM-4.57.0:HSL=v4.41.0:2020-05-21T18:29:34+0000:422a1f74d5f744078d1a5aba910cd7ced3e6f419
- Page requested: /hack/functions/anonymous-functions
- Page requested at: Wed, 24 Jun 2020 18:38:34 +0000
- Controller: GuidePageController