Re: Draft RFC: foreach iteration of keys without values
| From: | Sara Golemon | Date: | Wed, 02 Sep 2020 16:53:22 +0000 |
| Subject: | Re: Draft RFC: foreach iteration of keys without values | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111785@lists.php.net to get a copy of this message | ||
On Wed, Sep 2, 2020 at 9:31 AM Thomas Bley <mails@thomasbley.de> wrote:
> Hello,
>
> I'd also like to propose to use null:
>
> [null, null, $username] = getUserData();
>
> foreach ($source as $key => null) {}
>
>
These both look like great, expressive syntaxes. No new keywords, no major
change to existing idioms, just using up some otherwise unused space.
1. Are there other places this idiom might make sense?
2. Should we consider making them separate votes? Or taken as a whole?
-Sara