keyMatch

Tests whether two keys are equal for dictionary purposes.

Category: Language Fundamentals > Data Types

Syntax

tf = keyMatch(k1, k2)

Returns true if k1 and k2 are the same key.

Description

keyMatch is the equality test of a dictionary lookup. It is stricter than isequal in the sense that the two keys must be of the same kind, and text is compared case-sensitively. Together with keyHash it defines when two keys count as one entry.

Input arguments

k1, k2
Two key values.

Output arguments

tf
Logical scalar.

Example

Comparing keys

keyMatch('ab', 'ab')
keyMatch('ab', 'AB')
keyMatch(1, 1)
Output
ans = logical
   1
ans = logical
   0
ans = logical
   1

See also

keyHash dictionary isequal isKey