Skip to content

New DefaultDictionary constructors #46

@dninemfive

Description

@dninemfive

i came across a scenario in mzk where i wanted to make a DefaultDict which parsed a string into a key (different from the original string) and a value, like so:

// e.g. #EXT-TAG-EXAMPLE tag_value
new DefaultDictionary<string, List<string>>(x => {
  string[] split = x.Split(" ");
  string key = split.First();
  string firstValue = split.Skip(1).Join(" ");
  return (key, [firstValue]);
});

This would be a good utility to have, increasing the versatility of the DefaultDictionary class. Obviously, overloads such as Func<T, Tuple<K, V>> would be helpful too.

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions