On Thu, Jan 25, 2024, 11:16 Robert Landers <[email protected]> wrote:
> Hello internals,
>
> Now that throwing is an expression, it allows for some very concise
> programming. What are your thoughts on making a break/continue into an
> expression as well?
>
> Instead of:
>
> while(true) {
> ...
> if(is_null($arr['var'])) continue;
> if($something) continue; else break;
> ...
> }
>
> You could write
>
> while(true) {
> ...
> $arr['var'] ?? continue;
> $something ? continue : break;
> ...
> }
>
> Robert Landers
> Software Engineer
> Utrecht NL
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
Me personally would love to see `return` receive such treatment too!
(for a SerenityOS-like pattern of returning ”ErrorOr”-like objects)
P.S. sorry for a simple ”me too” reply
>