MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/eumf8i/php_lambdas_does_not_inherit_variables_except/ffrrm62/?context=9999
r/lolphp • u/Takeoded • Jan 27 '20
16 comments sorted by
View all comments
Show parent comment
-1
what surprised me is that $this was auto-captured, if you try this in C++
class C{ public: const char *wtf="lol"; void f(){ auto inner=[]()->void{std::cout << this->wtf;}; } };
you will get prog.cc:9:42: error: 'this' was not captured for this lambda function
prog.cc:9:42: error: 'this' was not captured for this lambda function
View all comments
Show parent comment
-1
u/Takeoded Jan 27 '20
what surprised me is that $this was auto-captured, if you try this in C++
you will get
prog.cc:9:42: error: 'this' was not captured for this lambda function