Julia Data Types

Julia is a dynamically typed language. Values have a concrete type.


Type Hints

To provide the interpreter/compiler a type hint, try:

julia> (1+2)::Int

This acts as a type assertion: if the annotated value is not that type, then a type error is thrown.


Abstract Types

Abstract types should not be used directly. They are supertypes that categorize behaviors. They are however useful for constructing a novel data type, or for typing the arguments to a function.

The primary set of abstract types, with their hierarchy of supertypes and subtypes indicated by indentation, is:


Numeric Types

The set of primitive types that descend from the Number abstract type are:


String Types

String is a subtype of AbstractString that implicitly is encoded in UTF-8.

Packages may create novel subtypes of AbstractString, so consider typing string arguments for functions as AbstractString rather than String.

Char is a subtype of AbstractChar, and is a 32-bit representation a Unicode character.


CategoryRicottone