Skip to content

[Proposal]: Immediately Enumerated Collection Expressions #9754

@RikkiGibson

Description

@RikkiGibson

Summary

Permit collection expressions in "immediately enumerated" contexts, without requiring a target type.

foreach (bool b in [true, false])
{
    doMyLogicWith(b);
}

string[] items1 = ["a", "b", .. ["c"]];
string[] items2 = ["a", "b", .. includeRest ? ["c", "d"] : []];

See also #9739.

Design meetings

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions