Also voting no, and wished I had mailed earlier.

Accessing the keys and values separately is not a good design in my
opinion, as it leads to:

> All four functions either return the requested key/value
> or null if an empty array is provided.

Having what looks likes valid values returned for array_value_first()
and array_value_last()

A think a better pattern would be to return a tuple as Levi suggested.

[$key, $value] = array_first($array);
[$key, $value] = array_last($array);

For people not used to returning tuples.....you should branch out a
bit and try using them.

They are a better pattern to  use when returning multiple values from
a function that don't need/deserve their own class/struct creating.

cheers
Dan
Ack


On 9 July 2018 at 18:31, CHU Zhaowei <m...@jhdxr.com> wrote:
> I voted no.
> I don't think we have an agreement on dealing with non-existing value, and 
> the way this RFC proposed, just returning null without any notice/warning, is 
> wrong IMO. I know we already do this in other array_* functions, but we 
> cannot keep making mistakes just because we already made same mistake.
>
> Regards,
> CHU Zhaowei

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to