SameQ
lhs === rhs
evaluates to True if lhs
and rhs
are identical after evaluation, False otherwise.
Attributes[SameQ] := {Protected}
Simple examples
In[1]:= a===a Out[1]= True
In[2]:= 5 === 5 Out[2]= True
Unlike Equal, SameQ does not forgive differences between Integers and Reals:
In[3]:= 5 === 5. Out[3]= False
SameQ considers the arguments of all expressions and subexpressions:
In[4]:= foo[x == 2, y, x] === foo[x == 2, y, x] Out[4]= True
In[5]:= foo[x == 2, y, x] === foo[x == 2., y, x] Out[5]= False
Further examples
SameQ does not match patterns:
In[1]:= {1, 2, 3} === _List Out[1]= False
This functionality is reserved for MatchQ:
In[2]:= MatchQ[{1, 2, 3}, _List] Out[2]= True