Erik Engheim

Mar 9, 2019

2 min read

Type Annotations in Julia and Python

In Julia using type annotations is an integral part of writing Julia code. For Python however this is a fairly recent addition (version 3.5), which as of this writing (March 2019) has not been standardized. In Python they are referred to as type hints.

In Julia we would normally write a function incrementing an integer like this:

inc(a::Integer) = a + 1

This allows us to catch potential wrong usage of the function.

julia> inc(4)

julia> inc(nothing)
ERROR: MethodError: no method matching