HH\Pair::filter

Returns a ImmVector containing the values of the current Pair that meet a supplied condition.

Description

public function filter(
  callable $callback,
): ImmVector<mixed>

Returns a ImmVector containing the values of the current Pair that meet a supplied condition.

Only values that meet a certain criteria are affected by a call to filter(), while all values are affected by a call to map().

Parameters

  • callable $callback - The callback containing the condition to apply to the current Pair values.

Return Values

Examples

<?hh

namespace Hack\UserDocumentation\API\Examples\Pair\Filter;

$p = Pair {null, -1.5};

$v = $p->filter($value ==> $value !== null);
var_dump($v);
Output
object(HH\ImmVector)#3 (1) {
  [0]=>
  float(-1.5)
}