Re: [RFC] Destructuring Coalesce
| From: | Bob Weinand | Date: | Thu, 03 Nov 2022 19:38:26 +0000 |
| Subject: | Re: [RFC] Destructuring Coalesce | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118954@lists.php.net to get a copy of this message | ||
Hey,
> Am 16.10.2022 um 23:56 schrieb David Rodrigues <david.proweb@gmail.com>:
>
> I like it!
>
> But what should happen if:
>
> [ $a ?? '123', $b ] = [];
$a is assigned 123, $b emits undefined key error.
> [ $a ?? '123', $b ] = [ 1 ];
$a is assigned 1, $b emits undefined key error.
> [ $a ?? '123', $b ] = [ 1, 2 ];
$a is assigned 1, $b is assigned 2.
> It also supports ?: operator?
>
> [ $a ?: '123' ] = []; so $a = '123'
> [ $a ?: '123' ] = [ false ]; so $a = '123'
> [ $a ?: '123' ] = [ 456 ]; so $a = 456
?: is out of scope of this RFC; a future RFC may want to take care of that.
Bob