HH\Set::lastValue

Returns the last value in the current Set

Description

public function lastValue(): ?Tv

Return Values

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

Examples

This example shows how lastValue() can be used even when a Set may be empty:

<?hh

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

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

$s = Set {};
var_dump($s->lastValue());
Output
string(6) "yellow"
NULL