HH\Set::items
Returns an Iterable
view of the current Set
public function items(): HH\Rx\Iterable<Tv>;
The Iterable
returned is one that produces the values from the current
Set
.
Returns
Examples
This example shows that items()
returns an Iterable
view of the Set
. The Iterable
will produce the values of the Set
at the time it's iterated.
$s = Set {'red', 'green', 'blue', 'yellow'};
// Get an Iterable view of the Set
$iterable = $s->items();
// Add another color to the original Set $s
$s->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