# Disambiguating variable names in string interpolation

**URL:** <https://discourse.julialang.org/t/disambiguating-variable-names-in-string-interpolation/98997>\
**Category:** New to Julia\
**Created:** [May 17, 2023, 12:30pm UTC](https://discourse.julialang.org/t/disambiguating-variable-names-in-string-interpolation/98997 "2023-05-17T12:30:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chskcau](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@chskcau](https://discourse.julialang.org/u/chskcau)\
**Post date:** [May 17, 2023, 12:30pm UTC](https://discourse.julialang.org/t/disambiguating-variable-names-in-string-interpolation/98997/1 "2023-05-17T12:30:16Z")

</div>

I’ve got another newbie question. In Julia it’s possible to interpolate strings into one another, e.g.

```julia
julia> greet = "Howdy"
"Howdy"

julia> whom = "cowgirls"
"cowgirls"

julia> "$greet, $whom"
"Howdy, cowgirls"

julia>

```

However, when adding an exclamation mark after `$whom`, Julia tries to interpolate the variable `whom!` instead:

```julia

julia> "$greet, $whom!"
ERROR: UndefVarError: whom! not defined
Stacktrace:
 [1] top-level scope
   @ REPL[52]:1

julia>

```

My question is, how do you avoid that? My first instinct was to use curly braces, i.e.

```julia
julia> "$greet, ${whom}!"
ERROR: syntax: invalid interpolation syntax: "${"
Stacktrace:
 [1] top-level scope
   @ none:1

julia>

```

but as you can see this didn’t work, and neither did escaping the exclamation mark,

```julia
julia> "$greet, $whom\!"
ERROR: syntax: invalid escape sequence
Stacktrace:
 [1] top-level scope
   @ none:1

julia>

```

As always, thanks a lot!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [May 17, 2023, 12:32pm UTC](https://discourse.julialang.org/t/disambiguating-variable-names-in-string-interpolation/98997/2 "2023-05-17T12:32:24Z")

</div>

normal parentheses, `"$(whom)!"`

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [May 17, 2023, 12:59pm UTC](https://discourse.julialang.org/t/disambiguating-variable-names-in-string-interpolation/98997/3 "2023-05-17T12:59:47Z")

</div>

a more artisanal workaround

```julia
"$greet, $whom"*'!' 

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 17, 2023, 1:10pm UTC](https://discourse.julialang.org/t/disambiguating-variable-names-in-string-interpolation/98997/4 "2023-05-17T13:10:19Z")

</div>

> [@rocco\_sprmnt21](#):
>
> a more artisanal workaround

Whether it is “more artisanal” is a matter of taste, but using `*` in this way allocates an extra temporary string, unfortunately.
