Skip to content

toMap function #5988

@soricinae

Description

@soricinae

Hello, please add a _collection.toMap(keySelector, [valueSelector]) function, so I can do this:

collection.toMap(x => x.key)

instead of this:

new Map(collection.map(x => [x.key, x]))

Please also add .toMap() to the groupBy() result so I can do this:

.groupBy(x => x.key).toMap(x => x.Key, x => x)

instead of this:

new Map(.groupBy(x => x.key).map((values, key): [string, T[]] => [key, values]).value())

Inspiration: https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.todictionary?view=net-9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions