One might add to Kuba's answer that x
and x$
are distinct symbols. The $
does not mean anything. It is added to the symbol name of x
to create a different symbol. Both fortunately and unfortunately, this behavior is predictable. If you wanted to inject a function body e
that has the Function
variable in it, you can use x$
instead of x
and count on the variable being rewritten x$
.
With[{e = x$}, Function[x, e]]
(* Function[x$, x$] *)
On the other hand, if you wanted the symbol x$
to be distinct symbol from the Function
variable, then the above code wouldn't work. You would have to use the ReplaceAll
form Function[x, e] /. e -> x$
. But since this rewriting happens in various contexts, better advice is the following:
Do not end the names of variables with a $
.