I have this code block in my script with an if/then/else but I want to know if it can also be done with a Lambda instead and if so, how I can implement it.
void DoThis(){
var enemies = FindComponentsOfType(typeof(Stats))..gameObject.where x != gameObject;
}
I don’t think that’s the right way to handle that. If you’re going to be operating on IEnumerable anyway, use one to start with. In general, though, you posted too much that was irrelevant to the question, or unknown to us. Please try to provide more clarity in the future.
void DoThis() { // Why is this relevant to your question?
var enemies // This name doesn't make sense. You're getting Stats. Stats are not enemies.
= Components // What goes here? Is it even relevant to your question?
.OfType<Stats>()
.Where(stats => stats.gameObject != gameObject);
}