Can't find the error on Instantiate

I made a code to random spawn a prefab on scene, was a simples code, and its giving an error, I saw on Unity Documentation and it’s the SAME CODE !

ERROR: RandomSpawn.cs(17,76): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement,

The error is on Instantiate

My code:

	class RandomSpawn : MonoBehaviour
        public GameObject[] spawn;

        public void Start()

        public IEnumerator Generate()
            yield return new WaitForSeconds(1);
            Vector3 position = new Vector3(Random.Range(-10.0F, 10.0F), 0, Random.Range(-10.0F, 10.0F));
            Instantiate(spawn, position, Quaternion.identity) as GameObject;

Unity Link code HERE

There is basically 2 errors.

  1. Instantiate receive a Object as argument, not an array of objects.

  2. Appear that C# could only allow you to cast for something if you assign it into a variable

Changing this line of code, works.

var obj = Instantiate(spawn[0], position, Quaternion.identity) as GameObject;