Hi Gina On Mon, Oct 21, 2024 at 3:21 PM Gina P. Banyard <intern...@gpb.moe> wrote: > > On Sunday, 20 October 2024 at 18:42, Gina P. Banyard <intern...@gpb.moe> > wrote: > > > https://wiki.php.net/rfc/array-sort-return-array > > For an example, I'm going to pull out my solution to day 1 of the 2022 > advents of code: > > https://github.com/Girgias/advent-of-code/blob/19283e1f5ef503c8a4478e58aaa57ff2fb7164c7/2022/01/puzzle.php#L25 > > > However, if the sort functions would return a useful value instead of `true` > I could chain it together completely as follows: > > $top3 = array_slice( > rsort( > array_map( > 'array_sum', > array_map( > fn($v) => explode("\n", $v), > explode( > "\n\n", > $input > ) > ) > ) > ), > 0, > length: 3 > );
Note that your example would still warn after this RFC, which is likely enough to deter people from writing code like this. https://3v4l.org/mRuoK