Before we go any further and start exploring Julia's types system in detail, we need to know what types are, and why they are even required.
To answer this question, consider the following four lines:
1 1.10 'j' "julia"
What do we see here? For sure, it's very plain and simple for us to understand that all four lines have different kinds of data. Starting from the first line: we have 1
, which is an integer; 1.10
, which is a float (or decimal); 'j'
, which represents a single character; and lastly, "Julia"
, which is a simple string made from a collection of characters used together.
But, even though we have prior knowledge about the data types in use, how do we let the machine know the same? How will the computer know that 1
is an integer, and not a float or a string? Well, the answer to this question is types!