# Using :> vs -> in SequenceReplace

The first example on the page for SequenceReplace is the following:

SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e]

(*b,x,x,c*)

Why do they use RuleDelayed here, instead of ->? I tried it with -> and got the same answer.

• In general, when working with patterns, it's just safer. For ->, e is only bound by e_ if it is present in the rhs after evaluation. So for example, e = 1; SequenceReplace[{a, b, x, x, a, c}, {a, e_} -> e] gets you {1, x, x, 1}. So it's good practice to use :> just in case e is defined somewhere else, I think. Sep 5 '21 at 19:24

I remember this was asked before, but can't find it now. i.e. when to use :> vs ->. As @thorimur mentions, it is related to when right side is evaluated.
If you have Wagner book, look at page 148, he gives a nice example showing when to use and what problem it can cause if you use -> instead of :>