Error in creating own data type

I am trying to create my own pointer structure for a binary tree. I am starting with this simple code

type int_BST
    key::Int64
    left::Nullable{int_BST}
    right::Nullable{int_BST}
end

but I keep getting the error

ERROR: LoadError: syntax: extra token "int_BST" after end of expression
Stacktrace:
 [1] include at ./boot.jl:326 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1038
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] include(::String) at ./client.jl:403
 [5] top-level scope at none:0
in expression starting at /data/dass/Julia/int_BST.jl:1

I realize this is a very basic issue, and any help would be appreciated.

The keyword for creating a struct is struct (it used to be type on older version of julia but it isn’t anymore):

mutable struct int_BST
    key::Int64
    left::Nullable{int_BST}
    right::Nullable{int_BST}
end

see: https://docs.julialang.org/en/v1/manual/types/#Composite-Types-1

If I’m not mistaken, Nullable is not used anymore. I’m guessing you are looking for something like:

mutable struct int_BST
    key::Int64
    left::Union{int_BST,Nothing}
    right::Union{int_BST,Nothing}
end

and use nothing (the instance of the Nothing type).

1 Like

Thank you very much for the quick reply, that worked. I will also check the link that you sent.