HH\Pair::containsKey

Checks whether a provided key exists in the current Pair

Description

public function containsKey<Tu super int>(
  Tu $k,
): bool;

This will only return true for provided keys of 0 and 1 since those are the only two keys that can exist in a Pair.

Parameters

  • $k - the key to check existance for in the Pair.

Return Values

  • bool - true if the provided key exists in the Pair; false otherwise. This will only return true if the provided key is 0 or 1.

Examples

<?hh

namespace Hack\UserDocumentation\API\Examples\Pair\ContainsKey;

$p = Pair {'foo', -1.5};

// Prints "true", since index 0 is the first value
var_dump($p->containsKey(0));

// Prints "true", since index 1 is the second value
var_dump($p->containsKey(1));

// Prints "false", since a Pair only has index 0 and index 1
var_dump($p->containsKey(2));
Output
bool(true)
bool(true)
bool(false)