HH\Lib\Vec\unique_by

This API is part of the Hack Standard Library, not HHVM itself.
Facebook Engineer?

This function is available as Vec\unique_by() in Facebook's www repository.

Returns a new vec containing each element of the given Traversable exactly once, where uniqueness is determined by calling the given scalar function on the values

Description

namespace HH\Lib\Vec;

function unique_by<Tv, Ts as arraykey>(
  Traversable<Tv> $traversable,
  (function(Tv):Ts) $scalar_func,
): vec<Tv>;

In case of duplicate scalar keys, later values will overwrite previous ones.

For arraykey elements, see Vec\unique().

Parameters