Re: [RFC][DISCUSSION] Collection Inspection
| From: | Michael Morris | Date: | Mon, 29 Jan 2018 21:35:18 +0000 |
| Subject: | Re: [RFC][DISCUSSION] Collection Inspection | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101724@lists.php.net to get a copy of this message | ||
On Mon, Jan 29, 2018 at 3:26 PM, Rowan Collins <rowan.collins@gmail.com>
wrote:
>
> Nor are generators the only non-rewindable iterables you need to worry
> about, so really the only options you have are to only inspect arrays, or
> to add a big fat warning that the function may consume your iterable (or
> enter an infinite loop).
>
>
Sorry about the double reply. What about using count() as a guard? While
there might be some countable consumables, my understand of generators is
they are often used where no prior count is available. Arrays and
ArrayObjects are countable.