I tried a simple code with julia:
x = readline()
print(String(“Hello, $x!”))
and Julia took the variable as “x!”, instead of “x”.
But, it was just fine when I changed the “!” with “.”
Is “!” a special character or else?
I need some explanation. Thank you!
1 Like
julia> x = 3; print(String("Hello, $(x)!"))
Hello, 3!
4 Likes
WschW
July 18, 2020, 4:36am
3
Nothing special about the !
in this context. It is just that x!
is a valid variable name.
4 Likes
Oh okay, that works . Thank you very much!
Thank you for the answer. I didn’t know if Julia accept such “!” character as a valid variable, unlike Python.
1 Like
jling
July 18, 2020, 4:46am
6
you can see a lot of functions has !
in them, such as push!
, to hint an in-place operation or side-effect (non-pure).
1 Like
Perfect. But just to complement, it is worth mentioning that a valid function name is also a valid variable name. So what is seen in function names can also be seen in variable names.