On 2026-10-24 12:16, mickmackusa wrote:
Hi Ayoub,

- It feels unintuitive that `true` callback outcomes map to the `0` key and `false` outcomes map to `1`.
I'm also in support, and this would have been my only observation: my partition functions also map passes and rejects to true and false respectively (so the result is a mapping from booleans to array values).

If that mapping were retained, it could be documented in code as

[true => $passed, false => $rejected] = array_partition(...);

or

$adult_tested = array_partition(...);

$adults = $adult_tested[true];
$minors = $adult_tested[false];






I would also prefer the callback parameter to be named $predicate, to emphasise that it is supposed to return a boolean. $callback doesn't convey as much about what it's for - the same name is used, for example, in usort(), where it's a comparator. It didn't matter until named parameters became a thing.

Reply via email to