Different resharper warnings... (Assignment is redundant + Parameter can be IEnumerable)

I’m trying to clean up my code to get rid of a lot of resharper (omnisharp) warnings that are annoying. I’m a noob but I’d like to understand them :slight_smile:

Warning : Assignment is redundant - (27, 13)

26: var anim = newUnit.GetComponent<Animator>();
27: var agent [B]=[/B] newUnit.GetComponent<NavMeshAgent>();

I can’t see the difference, why is it saying that on line 27, but not on 26? The only thing that I can see differs is that NavMeshAgent is from UnityEngine.AI and Animator is from UnityEngine.

Parameter can be IEnumerable - (329, 56)

329: IEnumerator ResetLayers(float timer, IEnumerable<int> [B]layers[/B], float startWeight = 0, float endWeight = 1) { //, int[] layers,

It used to be int[ ] layers, but I got the same error, and tried to change it like what’s above.

Thanks in advance! :slight_smile:

For the first one, check that you are actually using the local variable agent
I’m not sure about the second. Seems like you made the suggested change already… Could be a cached result and you need to rebuild, or it could be referring to another method and you missed the line number.

Thanks, I’ll check that out :slight_smile:

Ah, figured it out. There’s nothing in the part of the code actually using “agent”, so it’s redundant and pointless. Actually the line using it was commented out.

The IEnumerable is still there, so it’s maybe a cache like you suggested.