Re: Empty subject in match and switch constructions
| From: | Dmitry Derepko | Date: | Tue, 04 Feb 2025 09:34:06 +0000 |
| Subject: | Re: Empty subject in match and switch constructions | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-126281@lists.php.net to get a copy of this message | ||
Hi, Claude!
> On Feb 4, 2025, at 11:44 AM, Claude Pache <claude.pache@gmail.com> wrote:
>
> Hi,
>
> One issue to resolve is how to interpret:
>
> ```php
> $x = match {
> preg_match('/a/', 'a') => "will it be matched ..."
> , default => "... or not?"
> };
> ```
>
> —Claude
I wouldn’t discuss it there because the proposal is only about short syntax.
So making “match” work in different way is not a goal for the change.
It must work as full form “match(true)”: strict match, which is "===“.
If you’re going to use non-strict comparison check “switch” operator: https://3v4l.org/tHkJu
Anyway, as for me it should be another thread. Thanks!
----------
Best regards,
Dmitrii Derepko.
@xepozz