C
C#4mo ago
Pokruk

✅ Syntax sugar for coroutines

Why can I do this
IEnumerator WaitForSomehting() {
yield return resp.WaitResult();
Debug.Log("Wrapper res" + resp.result);
Debug.Log("Wrapper error" + resp.error);
}
SomeMonoBehaviour.Instance.StartCoroutine(WaitForSomehting);
IEnumerator WaitForSomehting() {
yield return resp.WaitResult();
Debug.Log("Wrapper res" + resp.result);
Debug.Log("Wrapper error" + resp.error);
}
SomeMonoBehaviour.Instance.StartCoroutine(WaitForSomehting);
But not this?
SomeMonoBehaviour.Instance.StartCoroutine(() => {
yield return resp.WaitResult();
Debug.Log("Wrapper res" + resp.result);
Debug.Log("Wrapper error" + resp.error);
});
SomeMonoBehaviour.Instance.StartCoroutine(() => {
yield return resp.WaitResult();
Debug.Log("Wrapper res" + resp.result);
Debug.Log("Wrapper error" + resp.error);
});
No description
3 Replies
ero
ero4mo ago
Because anonymous functions simply cannot be iterators That's not something that exists in C#
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX4mo ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?