hphp/hack/manual/apis/Interfaces/HH/KeyedIterable/index.md
:::info[Note] This is a point-in-time snapshot of the API documentation from January 2026. Going forward, we will not be maintaining a public copy of these references, and recommend users to refer to the built-in signature helpers available in the Hack LSP instead for complete and up-to-date information. :::
Represents any entity that can be iterated over using something like
foreach
The entity is required to have a key in addition to values.
KeyedIterable does not include arrays.
namespace HH;
interface KeyedIterable implements Iterable<Tv>, KeyedTraversable<Tk, Tv> {...}
->concat<Tu super Tv>(Traversable<Tu> $traversable): Iterable<Tu>Iterable that is the concatenation of the values of the
current KeyedIterable and the values of the provided Traversable->filter((function(Tv): bool) $fn): KeyedIterable<Tk, Tv>KeyedIterable containing the values of the current
KeyedIterable that meet a supplied condition->filterWithKey((function(Tk, Tv): bool) $callback): KeyedIterable<Tk, Tv>KeyedIterable containing the values of the current
KeyedIterable that meet a supplied condition applied to its keys and
values->firstKey(): ?TkKeyedIterable->firstValue(): ?TvKeyedIterable->getIterator(): KeyedIterator<Tk, Tv>KeyedIterable->keys(): Iterable<Tk>Iterable containing the current KeyedIterable's keys->lastKey(): ?TkKeyedIterable->lastValue(): ?TvKeyedIterable->lazy(): KeyedIterable<Tk, Tv>KeyedIterable->map<Tu>((function(Tv): Tu) $fn): KeyedIterable<Tk, Tu>KeyedIterable containing the values after an operation has been
applied to each value in the current KeyedIterable->mapWithKey<Tu>((function(Tk, Tv): Tu) $callback): KeyedIterable<Tk, Tu>KeyedIterable containing the values after an operation has
been applied to each key and value in the current KeyedIterable->skip(int $n): KeyedIterable<Tk, Tv>KeyedIterable containing the values after the n-th element
of the current KeyedIterable->skipWhile((function(Tv): bool) $fn): KeyedIterable<Tk, Tv>KeyedIterable containing the values of the current
KeyedIterable starting after and including the first value that produces
true when passed to the specified callback->slice(int $start, int $len): KeyedIterable<Tk, Tv>KeyedIterable starting from a given key
up to, but not including, the element at the provided length from the
starting key->take(int $n): KeyedIterable<Tk, Tv>KeyedIterable containing the first n values of the current
KeyedIterable->takeWhile((function(Tv): bool) $fn): KeyedIterable<Tk, Tv>KeyedIterable containing the values of the current
KeyedIterable up to but not including the first value that produces
false when passed to the specified callback->toImmMap(): ImmMap<Tk, Tv>ImmMap) based on the keys and values of the
current KeyedIterable->toKeysArray(): varrayarray with the keys from the current KeyedIterable->values(): Iterable<Tv>Iterable containing the current KeyedIterable's values->zip<Tu>(Traversable<Tu> $traversable): KeyedIterable<Tk, Pair<Tv, Tu>>KeyedIterable where each element is a Pair that combines the
element of the current KeyedIterable and the provided TraversableHH\Iterable)->toImmSet(): ImmSet<Tv>ImmSet) converted from the current Iterable->toImmVector(): ImmVector<Tv>ImmVector) converted from the current
Iterable->toValuesArray(): varray<Tv>array with the values from the current Iterable