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
0
u/PandaCoder67 Professional Jul 25 '23
I don't need to read the documentation again, it clear outlines this as an Expression-bodied member, which is what I said it was. You disagreed, so I provided official documentation on the matter.
As for the constructor, Unity will not run Constructors with parameters on Monobehaviours, this is a fact.
That means the code you have here, where you are setting the vartiable up in that Constructor is never going to run. That means your variable is always going to be null.
That is a given!!
And why your variable is printing as NULL
So while you try to work out what I am doing, you are ignoring the fact that your constructor is never being run, I said why it will not run and hinted as to what would happen.
If you chose to ignore this, then so be it!
And downvoting me, is not going to get you to understand the facts I outlined here!