I know that we can not use yield
in a try-catch
block according to the documentation:
A yield return statement can't be located in a try-catch block. A yield return statement can be located in the try block of a try-finally statement. A yield break statement can be located in a try block or a catch block but not a finally block.
I also know that Python has the same limitation.
My question is: Why?
Why does this result in a compiler error? Is there some sort of underlying reason why this isn't allowed?