Strings
Literal strings are always ASCII
(if they only contain ASCII letters) or UTF8
(if they contain characters that cannot be represented in ASCII), as in this example:
julia> typeof("hello") ASCIIString julia> typeof("Güdrun") UTF8String
UTF16
and UTF32
are also supported. Strings are contained in double quotes (" "
) or triple quotes (''' '''
). They are immutable, which means that they cannot be altered once they have been defined:
julia> s = "Hello, Julia" julia> s[2] = "z" ERROR: 'setindex!' has no method matching setindex!...
A String is a succession, or an array of characters (see the Ranges and arrays section) that can be extracted from the string by indexing it, starting from 1
: with str = "Julia"
, then str[1]
returns the Char 'J'
Get Getting Started with Julia now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.