Skip to content
Discussion options

You must be logged in to vote

That implies that such a feature could only ever be used if the compiler can prove that it's the only elements that could only ever be yielded down that path. But, even if it could, the compiler should definitely never do that implicitly as that radically changes the behavior of how iterator methods are expected to run. If there were to be an "eager" portion of an iterator that should have to be explicitly specified, and the compiler team has already considered a couple of proposals to that have have landed on local functions being a perfectly suitable way to accomplish that behavior:

    public static IEnumerable<int> DoSomething(IEnumerable<int> src) {
        if (src is int[] array) {

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@karakasa
Comment options

@HaloFour
Comment options

@karakasa
Comment options

@HaloFour
Comment options

Answer selected by karakasa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants