Drop Duplicates by Key, Keeping Item Types
Write the code, see it run, pass the checks.
The problem
- easy
- Code
Write uniqueBy(items, keyOf): return a new list with only the first item for each key keyOf gives, in their original order, leaving items unchanged. Keys are compared like a Set compares them. Type it so the result has the items' own type (a User[] stays User[]) and keyOf is given each item with that type, not any.
Your code must pass
- Keeps the first item for each key, in order
- Leaves the list unchanged
- Has no type errors
- Returns the items' type
- keyOf gets each item, typed