HH\Lib\Keyset\filter_nulls

Meta Engineer?

This is available as Keyset\filter_nulls in the www repository.

Returns a new keyset containing only non-null values of the given Traversable

namespace HH\Lib\Keyset;

function filter_nulls<Tv as arraykey>(
  Traversable<?Tv> $traversable,
): keyset<Tv>;

Time complexity: O(n) Space complexity: O(n)

Parameters

Returns

  • keyset<Tv>

Examples

$result = Keyset\filter_nulls(vec<int>[1,2,3,4,null, null]);
print_r($result);
//result: keyset[1,2,3,4]

$result = Keyset\filter_nulls(vec[1,2,3,4]);
print_r($result);
//result: keyset[1,2,3,4]

$result = Keyset\filter_nulls(vec[]);
print_r($result);
//result: keyset[]