Strings in Julia are delimited using the "
symbol:
julia> mystring = "Hello, World!"
"Hello, World!"
Note that unlike some other languages, the '
symbol cannot be used instead. '
defines a character literal; this is a Char
data type and will only store a single Unicode scalar value:
julia> 'c'
'c'
julia> 'character'
ERROR: syntax: invalid character literal
One can extract the unicode scalar values from a string by iterating over it with a for
loop:
julia> for c in "Hello, World!"
println(c)
end
H
e
l
l
o
,
W
o
r
l
d
!