Categories &

Functions List

Function Reference: keyMatch

datatypes: TF = keyMatch (A, B)

Return true if both inputs are the same key.

TF = keyMatch (A, B) returns a logical scalar, which is true, if the inputs A and B are the same key, and false otherwise. Two values are the same key when they have the same class, the same size, and equal contents, with missing values comparing equal to one another as in isequaln. Neither class nor size is promoted, so 1 and int8 (1) are different keys, and so are a row and a column holding the same elements.

keyMatch decides key identity and keyHash agrees with it: two values that keyMatch reports as the same key always have the same hash code. The converse does not hold, since distinct keys are permitted to share a hash code, and so comparing hash codes is not a substitute for calling keyMatch.

Both inputs must be of a type that can be a key, that is, one that keyHash can hash; anything else raises an error. Answering for a value that cannot be hashed would assert that two values are the same key, or are different keys, when no key exists for either.

Source Code: keyMatch