9  Functions

Define new functions with function:

function squared(x)
    x .^ 2
end
squared (generic function with 1 method)
squared(3)
9

Optionally define types using ::Type:

function squared(x::Float64)
    x .^2
end
squared (generic function with 2 methods)
squared(3)
9