value > threshold as a reusable predicate. Bind the threshold up front.
Creates a predicate Closure that is true when the passed number is strictly greater than the bound number.
/**
* @param int|float $a
* @return Closure(int|float):bool
*/
Comparisons\isGreaterThan($a): ClosureWhen Comparisons\isGreaterThan() is called, it returns the following Closure which can be used like a regular function.
/**
* @param int|float $b
* @return bool
*/
$function ($b): boolThis can be used to create a simple closure which can be used as a regular function.
$over18 = Comparisons\isGreaterThan(18);
var_dump($over18(21)); // true
var_dump($over18(18)); // false (strict)
var_dump($over18(17)); // false
$adults = array_filter([15, 18, 21, 30], $over18);
print_r($adults); // [21, 30]