Quantcast
Channel: Answers for "How to properly use Yield for a coroutine?"
Viewing all articles
Browse latest Browse all 6

Answer by Mike 3

$
0
0

the function that you call needs to be of type IEnumerator - this is done implicitly when you use yield in the function, but if you add in a return (or it is possible to get through the function without hitting a yield), it'll see it as a void function

if you want to tell the compiler to do it explicitly, you could do function myFirstFunction() : IEnumerator {

Edit - In the example you posted, the compiler can't be sure there will be a yield if the string is too short (0 chars) - so it's confused as to the return type

you could fix it by putting yield; at the end, or making the function IEnumerator


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>