Re: Draft RFC: foreach iteration of keys without values
| From: | Josh Bruce | Date: | Wed, 02 Sep 2020 13:15:55 +0000 |
| Subject: | Re: Draft RFC: foreach iteration of keys without values | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111779@lists.php.net to get a copy of this message | ||
> On Sep 2, 2020, at 6:27 AM, Dik Takken <dik.takken@gmail.com> wrote:
>
> On 02-09-2020 12:48, Olle Härstedt wrote:
>> An alternative syntax would be
>>
>> foreach($iterable as $key => _) { ... }
>>
>> Using underscore as a way to signal "I don't care about this value".
>> Same could be possible with list destructoring, like
>>
>> [_, _, $something] = foo();
>>
Swift also uses the underscore in places.
>> 1. It is currently a valid constant name (BC break)
I can name a constant an underscore??
Does anyone actually do this??
I guess I’m asking how impactful the break would be considering most magic things start with
double underscore and I haven’t seen many people using the single underscore to represent instance
variables anymore.