Skip to content

foreach/else #134

@lyubomyr-shaydariv

Description

@lyubomyr-shaydariv

The following proposal's value may be really low, nothing revolutionary, but sometimes one may need the code like the following:

// bar is an IEnumerable<T>
foreach ( var foo : bar ) {
    Console.WriteLine(foo);
} else {
    Console.WriteLine("no foos in the bar");
}

Just a little syntax sugar.

EDIT

Please note that there would be no a straightforward extension method: foreach might contain break, continue and return.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions