Print command in Julia

Hm, then you misread what I wrote or at least are not precise
If you have a string like

s = "HI!"
print(s)

works as well just fine

But if you want to bring a variable into a string – the so-called interpolation, then you do a $ upfront. That is maybe comparable, but not the same, as the %s fields in C/C++s sprints

An example

a=1 # Int
b=0.987 # Float
c = 1//2 # Rational
s = "We have $a, $b, and $c"

Then the String s looks like "We have 1, 0.987, and 1//2"
So the $ is used $ when constructing a string. Sure this might be a string in the argument of a print

5 Likes