Returns an Iterable view of the current Set

public function items(): Iterable<Tv>;

The Iterable returned is one that produces the values from the current Set.



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.

function basic_usage_main(): void {
  $s = Set {'red', 'green', 'blue', 'yellow'};

  // Get an Iterable view of the Set
  $iterable = $s->items();

  // Add another color to the original Set $s

  // 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');