Discussion: making continue and break into an expression
| From: | Robert Landers | Date: | Thu, 25 Jan 2024 09:16:20 +0000 |
| Subject: | Discussion: making continue and break into an expression | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-122253@lists.php.net to get a copy of this message | ||
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