Return When
| From: | Volodymyr Volynets | Date: | Tue, 26 Nov 2024 16:10:33 +0000 |
| Subject: | Return When | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-126059@lists.php.net to get a copy of this message | ||
Hi PHP Mailing list,
My username is vvolynets.
I have an idea which will save a lot of code. I am proposing to add":
return when [condition], [return value];
This construct will remove a lot of ifs statements after method calls. For
example:
$result = Class->method();
if (!$result['success']) {
return $result;
}
This becomes:
return when !$result['success'], $result;
Any thoughts?
Regards
Volodymyr Volynets