Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as C\last_key() in Facebook's www repository.

Returns the last key of the given KeyedTraversable, or null if the KeyedTraversable is empty

namespace HH\Lib\C;

function last_key<Tk, Tv>(
  KeyedTraversable<Tk, Tv> $traversable,
): ?Tk;

For non-empty Traversables, see C\last_keyx.

Time complexity: O(1) if $traversable is a Container, O(n) otherwise. Space complexity: O(1)



  • ?Tk