问题
In PHP 7.1 a new iterable pseudo-type was introduced.
Is there a straightforward way to transform a generic iterable
into an Iterator
? Or should I use something like
if (is_array($iterable)) {
return new \ArrayIterator($iterable);
}
return new \IteratorIterator($iterable);
来源:https://stackoverflow.com/questions/43474857/turn-iterable-into-iterator