Skip to main content
Tweeted twitter.com/StackMma/status/684839025107202048
edited body
Source Link

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 isit 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.

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.

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 it 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.

Source Link

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.