HH\Lib\Keyset\filter_nulls
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
Traversable<?Tv>
$traversable
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[]