# Documentation on the attribute OneIdentity [duplicate]

The documentation on the attribute OneIdentity says

OneIdentity is an attribute that can be assigned to a symbol f to indicate that f[x], f[f[x]], etc. are all equivalent to x for the purpose of pattern matching.

Then why does the input

SetAttributes[f,OneIdentity]
MatchQ[x, f[_]]


return False? On the other hand (from the examples in the documentation), the following input returns True:

SetAttributes[f, OneIdentity]
MatchQ[a, f[x_: 0, y_]]


Is there a problem with the documentation or am I misunderstanding it?

• What happens if you use f[__] (BlankSequence instead of Blank)? Jul 20 '15 at 12:06
• See here for an answer to your question. Jul 20 '15 at 12:14
• @Guesswhoitis. Still returns false. Jul 20 '15 at 12:24
• I think the definition given in the answer of the linked question is slightly wrong. For example, MatchQ[a,f[x_: 0, y_, __]] returns False even though there is one optional argument in the first two pattern argument positions (as stated in the linked answer). A more correct definition would be: there has to be at least one optional argument in f[...] and besides optional arguments there can be at most one argument that is not optional. Jul 21 '15 at 10:12