HH\Vector::items
Returns an Iterable
view of the current Vector
public function items(): HH\Rx\Iterable<Tv>;
The Iterable
returned is one that produces the values from the current
Vector
.
Returns
Examples
This example shows that items()
returns an Iterable
view of the Vector
. The Iterable
will produce the values of the Vector
at the time it's iterated.
$v = Vector {'red', 'green', 'blue', 'yellow'};
// Get an Iterable view of the Vector
$iterable = $v->items();
// Add another color to the original Vector $v
$v->add('purple');
// Print each color using $iterable
foreach ($iterable as $color) {
echo $color."\n";
}
// This wouldn't work because the Iterable interface is read-only:
// $iterable->add('orange');
red
green
blue
yellow
purple