Book Image

Getting Started with Julia

By : Ivo Balbaert
Book Image

Getting Started with Julia

By: Ivo Balbaert

Overview of this book

Table of Contents (19 chapters)
Getting Started with Julia
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The Rationale for Julia
Index

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', and str[end] returns the Char 'a', the last character in the string. The index of the last byte is also given by endof(str), and length() returns the number of characters. These two are different if the string contains multi-byte Unicode...