HH\Set::firstValue

Returns the first value in the current Set

Description

public function firstValue(): ?Tv

Return Values

  • ?Tv - The first value in the current Set, or null if the Set is empty.

Examples

The following example gets the first value from a Set. An empty Set will return null as its first value.

<?hh

namespace Hack\UserDocumentation\API\Examples\Set\FirstValue;

$s = Set {'red', 'green', 'blue', 'yellow'};
var_dump($s->firstValue());

$s = Set {};
var_dump($s->firstValue());
Output
string(3) "red"
NULL