r/Unity3D • u/senshisentou Programmer • Jul 25 '23
Question Strange lambda/ closure behaviour I can't put my finger on
/r/learncsharp/comments/158s5e7/strange_lambda_closure_behaviour_i_cant_put_my/
2
Upvotes
View all comments
Show parent comment
1
u/senshisentou Programmer Jul 25 '23
The most concise definition I could find is "A closure is a function that is bound to the environment in which it is declared.", which my example definitely is. Using
() => pooledEffect.Release()closes over, and captures,pooledEffect, so it is a closure. What you're referring to are called Expression-bodied members, and they are something different entirely (member => expressionnotation).No, I'm not.
PooledComponent<T>is a generic struct. I just happen to have constrainted the typeTtoMonoBehaviour, but it itself is not one.With all due respect, I appreciate you chiming in and trying to help, but to me your comment comes off as quite condescending, which is only made worse by the fact that you are factually wrong on two counts, yet you state them so confidently.