Skip to main content
1 of 2

ReplaceAll with Associations instead of Rules

I have just noticed that

x /. <|x -> 123|> 

evaluates to

123 

In other words, the association seems to behave as a rule. I didn't see any example or reference to this behavior in the ReplaceAll (/.) documentation. Is this undocumented? Is is OK to rely on this behavior?

While it may not make sense to use this for new code. It can be useful for simplifying to work needed to adapt old code to using associations.