yield new wait for seconds: what does "new" do?

I was experimenting with the Batching iPhone Example in the Example Projects section of the Unity webpage. There is a script called bullsEyeAnimationCycle.js:

function Awake () 
function playBullsEyeAnimation ()
    yield new WaitForSeconds (Random.Range (0.5, 2.0));
    yield new WaitForSeconds (animation["hide"].clip.length);
    Destroy (transform.root.gameObject);

What is the role of "new" after yield? I couldn't find anything in the Scripting Overview. Thanks :)

It creates a new instance of the type you put after it.


var x = new Vector3(1,2,3);

creates a new Vector3 instance.

In javascript it's generally optional, with the exception of arrays:

var x = new Vector3[8];

requires the new.

WaitForSeconds is actually a class which unity uses in coroutines for checking how long it should wait