Data is stored in values such as1
, 3.14
, and "Julia"
, and every other value has a type, for example, the type of 3.14
isFloat64
. Some other examples of elementary values and their data types are 42
of the Int64
type, true
and false
of the Bool
type, and 'X'
of the Char
type.
Julia, unlike many modern programming languages, differentiates between single characters and strings. Strings can contain any number of characters, and are specified using double quotes—single quotes are only used for a character literal. Variables are the names that are bound to values by assignments, such asx = 42
. They have the type of the value they contain (or reference); this type is given by the typeof
function. For example, typeof(x)
returns Int64
.
The type of a variable can change, because putting x = "I am Julia"
now results in typeof(x)
returning String
. In Julia, we don't have to declare a variable (that indicates its type) such as in C or Java, for instance, but...