user-documentation icon indicating copy to clipboard operation
user-documentation copied to clipboard

Document how lambdas capture local variables

Open jjergus opened this issue 4 years ago • 0 comments

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

jjergus avatar Jun 24 '20 18:06 jjergus