Reference a instantiated object?

So i have a question, heres some code.

			if(equipped == true){

			}else if(equipped == false){
GameObject item = (GameObject)Instantiate(inventory[selected], transform.parent.position, transform.parent.rotation) as GameObject;
			}

So now lets say i would like to acess the instantiated game object in the else if statement, How do i go about doing that? I’ve looked through some documentation but i cannot figure out how.

Finally I got what you are trying to say.
inside “if” you can do

  1. GameObject.Find() to get already equipped object. Change the name of object to something specific so that you can find it with it’s name.

  2. you can have Global reference to an GameObject and just access it inside if and change it when you instantiate inside else if.

if(equipped){
// do this
}else{
// removed implicit cast, not necessary when “as” casting
GameObject item = Instantiate(inventory[selected], transform.parent.position, transform.parent.rotation) as GameObject;
// access instantiated object using variable to which you assigned it
item.name = “SomeName”;
DoStuff(item);
}