Skip to content

Rename/alias Scheme<T>.Enumerate to GetEnumerator #32

@JonathanBout

Description

@JonathanBout

To support a cleaner foreach loop It'd be great to rename (or alias for backwards compatibility) Scheme<TColor>.Enumerate to Scheme<TColor>.GetEnumerator.

// old
foreach (var (key, color) in scheme.Enumerate())
{
    // ...
} 

// new
foreach (var (key, color) in scheme)
{
    // ...
}

This makes the use of it more C#-like. Just the method should be enough, but you might as well implement IEnumerable which supplies this exact method, and makes it LINQ-compatible.

I think it can be easily done from the source generator, by simply adding 1 extra line to the generated code:

public IEnumerator<KeyValuePair<string, TColor>> GetEnumerator() => Enumerate();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions