Help Understanding Coroutines and Yield

I’m unfamiliar with coroutines and yield. Is there a comprehensive tutorial on these things that explains how to use them and why you would use them.

http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield.html

This is okay but I’m confused about what the output would be in the examples. They should write out the order of what the user would see if they run the code.

Questions

function function2(){
Debug.Log("I am in function2");
}

function function1(){
Debug.Log("hello");
yield function2()
Debug.Log("goodbye");
}

What would this do if function1 is called. Would it
A) wait until function2 runs and then go back to function1?
B)just wait a frame. or would it not
C) Jump out of function1 never to return unless it’s called again.
D) Delay the update function until function2 is done?

Confused about how to use these in general.
I have one application where I have a long running for loop and I want to be able to break out if it is not going well. Would yield help me with that?

Thanks,

Dan

update can not be delayed, thats the worst and most error causing thing you can do as the next update call will happen independent of the one before finishing (actually you can’t yield in them anyway, it ends in an own function, it just doesn’t look like that in unityscript unhappily)

you can try reading this thread, focusing on Eric’s posts.
http://forum.unity3d.com/viewtopic.php?t=38049