Inline switch as alternative to nested inline conditional
| From: | David Rodrigues | Date: | Wed, 16 Oct 2019 01:46:35 +0000 |
| Subject: | Inline switch as alternative to nested inline conditional | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-107551@lists.php.net to get a copy of this message | ||
Hello. I like to suggests a discussion about a FR to make possible to
inline switch, as an alternative to nested inline conditionals.
$value = switch (expr()) {
case A1: return A2;
case B1: return B2;
default: return C;
}
Instead of:
$expr = expr();
$value = $expr == A1 ? A2 : ( $expr == B1 ? B2 : C );
Just a discussion to check what do you think.
--
David Rodrigues