{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Defining new types in Julia" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "mutable struct MyDiscreteWalker # capital letters for each word in type name -- camel case\n", " x::Int64\n", "end" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "mutable struct SomethingElse \n", " x::Int64 # several fields\n", " y::Float64\n", " name::String\n", "end" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "MyDiscreteWalker" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "MyDiscreteWalker # refers to the *type*" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "# 2 methods for type constructor: