Oh, yes...

On 2012-08-22 04:35, Lester Caine wrote:
 and doesn't seem to
provide any outstanding advantages?


As I wrote in an earlier post:

On 2012-08-09 15:30, Morgan L. Owens wrote:
> I for one am lazy, and would much prefer writing:
> <?php
> function append_iterator($first, $second)
> {
>    foreach($first as $i)
>    {
>        yield $i;
>    }
>    foreach($second as $i)
>    {
>        yield $i;
>    }
> }
> ?>
>
> to
>
> <?php
> 87 lines elided
> ?>

I'm not making any assumption about where the generator returned by append_iterator() is going to be used. In particular, it might not be in a public object method or other callable. But its use would probably look something like:

<?php
foreach(append_iterator($left, $right) as $i)
{
   ... do something with $i.
}
?>



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to