Pair is an immutable, fixed-size collection with exactly two elements (possibly of different types)

HHVM provides a native implementation for this class. The Hack class definition below is not actually used at run time; it is simply provided for the typechecker and for developer reference.

Like all objects in PHP, Pairs have reference-like semantics. The elements of a Pair cannot be mutated (i.e. you can't assign to the elements of a Pair) though Pairs may contain mutable objects.

Pairs only support integer keys. If a non-integer key is used, an exception will be thrown.

Pairs support $m[$k] style syntax for getting values by key. Pairs also support isset($m[$k]) and empty($m[$k]) syntax, and they provide similar semantics as arrays.

Pair keys are always 0 and 1, respectively.

You may notice that many methods affecting the instace of Pair return an ImmVector -- Pairs are essentially backed by 2-element ImmVectors.


Interface Synopsis

namespace HH;

final class Pair implements \ConstVector<mixed> {...}

Public Methods