Re: Discussion: making continue and break into an expression

From: Date: Thu, 25 Jan 2024 10:28:54 +0000
Subject: Re: Discussion: making continue and break into an expression
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-122254@lists.php.net to get a copy of this message
On Thu, Jan 25, 2024, 11:16 Robert Landers <landers.robert@gmail.com> 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 >

« previous php.internals (#122254) next »