Skip to main content
Post Closed as "Duplicate" by Mr.Wizard pattern-matching
Tweeted twitter.com/StackMma/status/912680627819958274
edited tags
Link
Source Link

Unexpected behavior using `ReplaceAll[]` for nested lists

ReplaceAll[] might lead to unexpected behavior (at least it surprised me). I use ReplaceAll[] to convert a list (basically data cleanup).

For the command:

{{1, "2"}, {2, "3"}} /. {x_, _ } :> {x, "SOMETHING"} 

I expected

{{1, "SOMETHING"}, {2, "SOMETHING"}} 

but got

{{1, "2"}, "SOMETHING"}.