Instantiate vs Instantiate as gameobject

Prototyping a 2d action roguelike(Enter The Gungeon/Nuclear Throne influenced) and I’m trying to figure out the difference between these two lines of code, and a sample use case for both:

  1. Using Instantiate to spawn a bullet prefab

    Instantiate (bullet, transform.position, Quaternion.identity);

vs

  1. Instantiating a prefab bullet as a GameObject

    GameObject projectile = Instantiate (bullet, transform.position, Quaternion.identity) as GameObject;

I’ve been searching around, and can find similar topics but none that address this question in this fashion(however that may be because of my search terms). Appreciate any help, thank you.

It’s called casting, and it’s used to convert an object from one type to another. Note it’s not specific to Instantiate at all - it’s part of C#.

Instantiate returns an Object. That’s not hugely useful. So the second example casts the result as a gameobject and then assigns it to the “projectile” variable so you can do other things with it.