Re: Two new functions array_first() and array_last()

From: Date: Wed, 18 Oct 2023 21:11:18 +0000
Subject: Re: Two new functions array_first() and array_last()
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-121424@lists.php.net to get a copy of this message
> Sure in many use cases undefined and null can be equivalent, but there > are other use cases and considering the fact that php does not have a > user level "undefined" value. It should at least attempt to not be > ambiguous when possible. Instead of being ambiguous by default, > requiring the user to do additional work to not be ambiguous. > > I do think the method is a great opportunity to avoid ambiguity, > without a huge sacrifice on cost. As you said, throwing an exception > would only further complicate things. Sure an empty check would get > the job done, but again I believe it should not require such > additional logic just to not be ambiguous. > Can we have ultimately a flag in the function for throwing an exception in case of empty array? Kind regards, Jorg

« previous php.internals (#121424) next »